iPhone UILabel text soft shadow

As of 3.2 there is direct support for shadows in the SDK. label.layer.shadowColor = [label.textColor CGColor]; label.layer.shadowOffset = CGSizeMake(0.0, 0.0); #import <QuartzCore/QuartzCore.h> and play with some parameters: label.layer.shadowRadius = 3.0; label.layer.shadowOpacity = 0.5; And, if you find your shadow clipped by the label bounds: label.layer.masksToBounds = NO; finally set label.layer.shouldRasterize = YES;

How to include and use new fonts in iPhone SDK?

Add the font files to your resource files Edit your Info.plist: Add a new entry with the key Fonts provided by application. For each of your files, add the file name to this array On the example below, I’ve added the font “DejaVu Sans Mono”: In your application you can the use [UIFont fontWithName:@”DejaVuSansMono-Bold” size:14.f]. … Read more

Prevent a UISearchDisplayController from hiding the navigation bar

I just debugged a bit into UISearchDisplayController and found that it’s calling a private method on UINavigationController to hide the navigation bar. This happens in -setActive:animated:. If you subclass UISearchDisplayController and overwrite this method with the following code you can prevent the navigationBar from being hidden by faking it to be already hidden. – (void)setActive:(BOOL)visible … Read more

How to intercept touches events on a MKMapView or UIWebView objects?

The best way I have found to achieve this is with a Gesture Recognizer. Other ways turn out to involve a lot of hackish programming that imperfectly duplicates Apple’s code, especially in the case of multitouch. Here’s what I do: Implement a gesture recognizer that cannot be prevented and that cannot prevent other gesture recognizers. … Read more

How to delete all Annotations on a MKMapView

Yes, here is how [mapView removeAnnotations:mapView.annotations] However the previous line of code will remove all map annotations “PINS” from the map, including the user location pin “Blue Pin”. To remove all map annotations and keep the user location pin on the map, there are two possible ways to do that Example 1, retain the user … Read more

How to detect when keyboard is shown and hidden

In the ViewDidLoad method of your class set up to listen for messages about the keyboard: // Listen for keyboard appearances and disappearances [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; Then in the methods you specify (in this case keyboardDidShow and keyboardDidHide) you can do something about it: – (void)keyboardDidShow: … Read more

tech