- 1. Turn color 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;
}
-(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. Get the current system language environment
nsuserdefaults* defs = [Nsuserdefaults standarduserdefaults];
nsarray* languages = [defs objectforkey:@ "Applelanguages"];
nsstring* Preferredlang = [languages objectatindex:0];
- 4. Calculating the height of a string
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 (maxfloat) options: Nsstringdrawinguseslinefragmentorigin Context:nil];
- 5. How to forcibly close the app
Private API
[[UIApplication sharedapplication] Performselector: @selector (terminatewithsuccess)];
C Language Method
Exit (0);