Some code snippets 1. hexadecimal color value conversion # define UIColorFromRGB (rgbValue) [UIColor colorWithRed :( (float) (rgbValue & 0xFF0000)> 16)/255.0 green :( (float) (rgbValue & 0xFF00)> 8)/255.0 blue :( (float) (rgbValue & 0xFF)/255.0 alpha: 1.0] 2. md5 + (NSString *) md5 :( NSString *) str {constchar * cStr = [str UTF8String]; unsignedcharresult [16]; CC_MD5 (cStr, strlen (cStr), result ); return [NSStringstringWithFormat: @ "XXXXXXXXXXXXXXXX ", Result [0], result [1], result [2], result [3], result [4], result [5], result [6], result [7], result [8], result [9], result [10], result [11], result [12], result [13], result [14], result [15];} 3. call // 1. Call the built-in mail [[UIApplicationsharedApplication] openURL: [NSURLURLWithString: @ "mailto: // admin@hzlzh.com"]; // 2. Call phone [[UIApplicationsharedApplication] openURL: [NSURLURLWithString: @ "tel: // 8008808888"]; // 3. Call SMS [[UIApplicationsharedApplication] openURL: [NSURLURLWithString: @ "sms: // 800888"]; // 4. Call the browser safari [[UIApplicationsharedApplication] openURL: [NSURLURLWithString: @ "http://www.hzlzh.com"]; // call phone can pass a number, call SMS can only set a number, Cannot initialize SMS content. 4. calculate the distance + (double) distanceBetweenOrderBy :( double) lat1 :( double) lat2 :( double) lng1 :( double) lng2 {CLLocation * curLocation = [[CLLocationalloc] initWithLatitude: lat1longlatitude: lng1]; CLLocation * otherLocation = [[CLLocationalloc] initWithLatitude: lat2longdistance: lng2]; doubledistance = [curLocation distanceFromLocation: otherLocation]; returndistance;} 5. whether there is a cross in the input box. When is it displayed? It is used to delete the text in the input box at a time. clearButton Mode = UITextFieldViewModeAlways; 6. iOS local push Step 1: create a local push // create a local push UILocalNotification * notification = [[uilocalnotifalloc] init] autorelease]; // set NSDate * pushDate = [NSDatedateWithTimeIntervalSinceNow: 10] after 10 seconds; if (notification! = Nil) {// set the push time notification. fireDate = pushDate; // set the time zone notification. timeZone = [nstimezonedefatimetimezone]; // you can specify the repetition interval notification. repeatInterval = kCFCalendarUnitDay; // push sound notification. soundName = UILocalNotificationDefaultSoundName; // push content notification. alertBody = @ "push content"; // display the number of notifications in the red circle on the icon. applicationIconBadgeNumber = 1; // set userinfo to enable NSDictionary * info = [NSDictio NarydictionaryWithObject: @ "name" forKey: @ "key"]; notification. userInfo = info; // Add push to UIApplication * app = [UIApplicationsharedApplication]; [receive chedulelocalnotification: notification];} Step 2: receive local push-(void) application :( UIApplication *) application didReceiveLocalNotification :( UILocalNotification *) notification {UIAlertView * alert = [[UIAlertViewalloc] initWithTitle: @ "iweio" message: notifica Tion. alertBodydelegate: nilcancelButtonTitle: @ "OK" otherButtonTitles: nil]; [alertshow]; // the number on the icon minus 1 application. applicationIconBadgeNumber-= 1;} Step 3: Release local push // obtain UIApplication * app = [UIApplicationsharedApplication]; // obtain the local push array NSArray * localArray = [app scheduledlocalconfigurications]; // declare the local notification object UILocalNotification * localNotification; if (localArray) {for (UILocalNotification * noti inlocalA Rray) {NSDictionary * dict = noti. userInfo; if (dict) {NSString * inKey = [dict objectForKey: @ "key"]; if ([inKey isEqualToString: @ "corresponding key value"]) {if (localNotification) {[localNotificationrelease]; localNotification = nil ;}localnotification = [noti retain]; break ;}}} // determine whether to find the push if (! LocalNotification) {// initialization localNotification = [[UILocalNotificationalloc] init] does not exist;} if (localNotification) {// do not push cancel push [appcancelLocalNotification: localNotification]; [localNotificationrelease]; return ;}} 7. click the link to jump directly to the App Store specified application download page // jump to the application page NSString * str = [NSStringstringWithFormat: @ "http://itunes.apple.com/us/app/id%d", appid]; [[UIApplicationsharedApplication] openURL: [NSURLurlWithString: str ]; // Jump to the rating page NSString * str = [NSStringstringWithFormat: @ "itms-apps: // ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews? Type = Purple + Software & id; = % d ", appid]; [[UIApplicationsharedApplication] openURL: [NSURLurlWithString: str]; 8. parent view does not respond to the touch event subview event-(id) hitTest :( CGPoint) pointwithEvent :( UIEvent *) event {idhitView = [superhitTest: pointwithEvent: event]; if (hitView = self) returnnil; elsereturn hitView;} 9. add the reflection effect constCGFloat kReflectPercent =-0.25f; constCGFloat kReflectOpacity = 0.3f; constCGFloat kReflectDistance = 10.0f; + (void) Comment: (UIView *) theView {CALayer * reflectionLayer = [CALayerlayer]; reflectionLayer. contents = [theView layer]. contents; reflectionLayer. opacity = kReflectOpacity; reflectionLayer. frame = CGRectMake (0.0f, 0.0f, theView. frame. size. width, theView. frame. size. height * kReflectPercent); percent = CATransform3DMakeScale (1.0f,-1.0f, 1.0f); CATransform3Dtransform = CATransform3DTranslate (stransform, 0.0f,-(kReflectDistance + theView. frame. size. height), 0.0f); reflectionLayer. transform = transform; reflectionLayer. sublayerTransform = reflectionLayer. transform; [[theViewlayer] addSublayer: reflectionLayer];}