(IOS) Small collection methods in development, ios development collection methods
-(UIImage *) createImageWithColor :( UIColor *) color
{
CGRect rect = CGRectMake (0.0f, 0.0f, 1.0f, 1.0f );
UIGraphicsBeginImageContext (rect. size );
CGContextRef context = UIGraphicsGetCurrentContext ();
CGContextSetFillColorWithColor (context, [color CGColor]);
CGContextFillRect (context, rect );
UIImage * theImage = UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext ();
Return theImage;
}
-(Void) goToAppStore
{
NSString * str = [NSString stringWithFormat:
@ "Itms-apps: // ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews? Type = Purple + Software & id = % d ", 547203890];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: str];
}
- 3. Obtain the current system language environment
NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
NSArray * ages = [defs objectForKey: @ "AppleLanguages"];
NSString * preferredLang = [ages objectAtIndex: 0];
- 4. Calculate the string height
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
ParagraphStyle. lineBreakMode = NSLineBreakByWordWrapping;
NSDictionary * dicAtt = [NSDictionary dictionaryWithObjectsAndKeys: [UIFont systemFontOfSize: 15], NSFontAttributeName, paragraphStyle. copy, NSParagraphStyleAttributeName, nil];
NSAttributedString * attribute = [[NSAttributedString alloc] initWithString: str attributes: dicAtt];
CGRect frame = [attribute boundingRectWithSize: CGSizeMake (200, MAXFLOAT) options: NSStringDrawingUsesLineFragmentOrigin context: nil];
- 5. Forcibly disable the app
Private API
[[UIApplication sharedApplication] performSelector: @ selector (terminateWithSuccess)];
C Language Method
Exit (0 );
Ios development process and Learning Method
If programming has no foundation, consider training.
If you have to do it yourself, go to the bookstore and look for books. You can purchase them if you can understand them.
In ios development, you may encounter many methods defined in system protocols that you do not understand.
This is the proxy method of the scrolling control that comes with ios. You can click command to view this method, or Baidu will know how to use UIPickerView.