1. Take a string in a string
[Plain] View plaincopyprint?
NSString *str [email protected]"12SADFSDF56AFSDF";
NSLog (@ "%@", str);
NSString *thrstr = [strstringbyreplacingoccurrencesofstring:@ "" withstring:@ "88"];
NSLog (@ "%@", thrstr);
That is, replace the 56 in 12SADFSDF56AFSDF with 88, and replace the string with the following: 12SADFSDF88AFSDF
2. Simple plist get
[plain] view plaincopyprint?
NSString *path = [[Nsbundlemainbundle] pathforresource:@ "Array" oftype:@ "plist"];  
nsmutabledictionary *data = [[Nsmutabledictionaryalloc] initwithcontentsoffile:path];
NSLog (@ "%d", [Datacount]);
NSLog (@ "%@", [ Dataallvalues]);
NSLog (@ "------------");
Nsarray *ary = [dataallkeys];
NSLog (@ "%d", [Arycount]);
Nsarray *array = [nsarrayarraywitharray:ary];
for (int i =0;i<[arraycount];i++)
{
nslog (@ "\ n value = %@ ", [arrayobjectatindex:i]);
}
Nsarray *getarray = [[ Dataallvalues]objectatindex:5];
NSLog (@ "get_array:%@", GetArray);
3. The status bar and Uinavigationbar are set to transparent
[[Uiapplicationsharedapplication]setstatusbarstyle:uistatusbarstyleblacktranslucent]; The status bar is set to transparent
TheNavigationController.navigationBar.barStyle =uibarstyleblacktranslucent; Set Navigationbar to Transparent
4. Set object fillet, such as UIView, Uiimageview, etc.
A few simple steps:
I. Import the QUARTZCORE.FRAMEWORK framework #import
Two. Object.layer.maskstobounds=yes;
Three. Object.layer.cornerradius=xxx;
[Plain] View plaincopyprint?
Uiimageview *testimageview = [[uiimageviewalloc]initwithimage:[uiimageimagenamed:@ "1.jpg"]];
[Testimageviewsetframe:cgrectmake (20,20,100,100)];
TestImageView.layer.masksToBounds =yes;
TestImageView.layer.cornerRadius =50/2; Set the angle to change the viewing effect
TestImageView.layer.borderWidth = 5; Border width
TestImageView.layer.borderColor = [Uicoloryellowcolor]. Cgcolor; Border color
[Self.viewaddSubview:testImageView];
[Testimageviewrelease];
5. The setup screen is lit when the program is in the boot state
UIApplication *appdelegate = [Uiapplicationsharedapplication];
Appdelegate.idletimerdisabled =yes;
6. Set UITableViewCell to display sub-headings
when initializing: cell = [[Uitableviewcellalloc]initwithstyle: uitableviewcellstylesubtitlereuseidentifier:cellidentifier];
The style should be noted here, which is set to show sub-heading styles, and the default style is not to display sub-headings, which are available after Setup: &NBSP
Cell.detailTextLabel.text [email protected] "detailed label"; set sub-headings
7. Set the shadow effect for UIView;
[plain] view plaincopyprint?
UIView *showview = [[ Uiviewalloc]initwithframe:cgrectmake (10,150,100,100)];
Showview.backgroundcolor = [ uicolorredcolor];
ShowView.layer.shadowOffset =cgsizemake (15,5);
ShowView.layer.shadowOpacity =0.6;
ShowView.layer.shadowColor = [Uicolorblackcolor]. cgcolor;
[self.viewaddsubview:showview];
[showviewrelease];
8. Set the location of the UITableView selected lines
[self.tableviewselectrowatindexpath:[ nsindexpathindexpathforrow:5insection:0]animated:noscrollposition:uitableviewscrollpositionmiddle];
//selectrowatindexpath Sets the number of rows and section scrollposition settings to scroll to (4 items to choose from)
9.UITextField agent for each operation call, can be changed according to requirements
-(BOOL) TextField: (Uitextfield *) TextField Shouldchangecharactersinrange: (nsrange) range replacementstring: ( NSString *) string
{
nsmutablestring *newstring = [[Textfield.textmutablecopy]autorelease];
[NewStringreplaceCharactersInRange:rangewithString:string]; The string that gets changed
}
10. How to generate UIImage with Uicolor
[Plain] View plaincopyprint?
-(void) viewdidload
{
[Superviewdidload];
Uiimageview *imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (10,10,100,100)];
UIImage *image = [self createimagewithcolor:[uicoloryellowcolor]; Create a picture of a yellow color
[Imageviewsetimage:image];
[Self.viewaddSubview:imageView];
[Imageviewrelease];
}
-(UIImage *) Createimagewithcolor: (Uicolor *) color
{
CGRect rect = CGRectMake (0.0f,0.0f,1.0f,1.0f);
Uigraphicsbeginimagecontext (rect.size);
Cgcontextref context =uigraphicsgetcurrentcontext ();
Cgcontextsetfillcolorwithcolor (context, [colorcgcolor]);
Cgcontextfillrect (context, rect);
UIImage *theimage =uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
return theimage;
}
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1827817
iOS Small method