Original link: http://blog.5ibc.net/p/90386.html
1. Color transforms into pictures
-(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;}
2, the method of forcibly closing the app
Private Api[[uiapplication sharedapplication] Performselector: @selector (terminatewithsuccess)];//C language method exit (0);
3, when using the View zoom, layer.border.width with the view magnification, there will be a jagged problem, to solve this problem need to set this familiar.
self.layer.allowsEdgeAntialiasing = YES;
4, button on Tableviewcell, click Get Location row
UITableViewCell *cell = (UITableViewCell *) [[btn Superview] superview]; Nsindexpath * Indexpath = [Self.tableview Indexpathforcell:cell];
5, iphone in order to save power so there is an automatic sleep mechanism, if you want to let our app does not automatically go to sleep only need to set uiapplication idletimerdisabled property is YES. (Never misuse)
6, Uiapplicationuserdidtakescreenshotnotification notification, when the user screenshots triggered
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (screencapture) Name: Uiapplicationuserdidtakescreenshotnotification object:nil];-(void) screencapture{ //dosomething}
iOS development-collection of infrequently used but useful small methods and tricks