18: Picture View several fill styles
_imgview.contentmode =Uiviewcontentmodescaleaspectfill, as follows: TypeDef ns_enum (Nsinteger, Uiviewcontentmode) { Uiviewcontentmodescaletofill, Uiviewcontentmodescaleaspectfit, Uiviewcontentmodescaleaspectfill, UIViewCon Tentmoderedraw,//Redraw on Bounds change (calls-setneedsdisplay)Uiviewcontentmodecenter,//contents remain same size. positioned adjusted.uiviewcontentmodetop, Uiviewcontentmodebottom, Uiviewcontentmodeleft, Uiviewcontentmoderight, UIViewCo Ntentmodetopleft, Uiviewcontentmodetopright, Uiviewcontentmodebottomleft, Uiviewcontentmodebottomright,}; Simple description: UIV Iewcontentmodescaletofill: Represents a fully populated frame. In Default Uiviewcontentmodescaleaspectfit: Maintain proportions, all in frame. Within Uiviewcontentmodescaleaspectfill: Maintain proportions, fill but frame. Outside. Uiviewcontentmoderedraw:? Uiviewcontentmodecenter: The center and frame of this image. The center of the product is coincident. Uiviewcontentmodetop: The top edge of this image and frame. Coincident with the top edge of the Uiviewcontentmodebottom: The bottom edge of this image is with frame. Coincident with the lower edge of the Uiviewcontentmodeleft: This image has the left edge and frame. The left edge of the image is coincident. Uiviewcontentmoderight: This image has the right edge and frame. Coincident to the right edge of the Uiviewcontentmodetopleft: Similar. Uiviewcontentmodetopright: Similar. Uiviewcontentmodebottomleft: Similar. Uiviewcontentmodebottomright: Similar.
Application of 19:uiview attribute Clipstobounds
= YES;
20:calayer several common settings
borders, rounded corners, shadows set rounded borders? SomeView.layer.cornerRadius=4.0f; SomeView.layer.masksToBounds=YES;//set border and border color? someView.layer.borderWidth =0.5f; SomeView.layer.borderColor=[[Uicolor Graycolor] cgcolor];?//add four edge shadows? _imgvphoto.layer.shadowcolor = [Uicolor blackcolor]. Cgcolor;? _imgvphoto.layer.shadowoffset = Cgsizemake (0,0);? _imgvphoto.layer.shadowopacity =0.5;? _imgvphoto.layer.shadowradius =10.0; _ ImgvPhoto.layer.masksToBounds=NO; //Add two edge shadows? _imgvphoto.layer.shadowcolor = [Uicolor blackcolor]. Cgcolor;? _imgvphoto.layer.shadowoffset = Cgsizemake (4,4);? _imgvphoto.layer.shadowopacity =0.5;? _imgvphoto.layer.shadowradius =2.0; Description: ①someview means UIView and the like; ② must be introduced: #import<QuartzCore/QuartzCore.h>
21:uiactionsheet Pop-Up display
#define Kkeywindow [uiapplication sharedapplication].keywindowdelegate: Self Cancelbuttontitle:@ " cancel " destructivebuttontitle:nil otherbuttontitles:@ " Photo "@" select from album , nil]; [Actionsheet Showinview:kkeywindow];
Application of 22:block callback parameters
There are two Viewcontroller, A/b, where a jumps to B, gets a value from B, jumps to a, and displays the value of B; The code is as follows: A.h-(ibaction) Otherstoryboard: (ID) sender; @property (weak, nonatomic) Iboutlet UILabel*LABLEINFO;A.M-(ibaction) Otherstoryboard: (ID) sender {uistoryboard* Mainstoryboard=[uistoryboard Storyboardwithname:@"Hotelstoryboard"Bundle:nil]; Hotelviewcontroller* Weathcontroller=[mainstoryboard Instantiateviewcontrollerwithidentifier:@"Hotelstoryboard"]; Weathcontroller.block=^ (nsstring*inputvalue) {Self.lableInfo.text=Inputvalue; }; [Self presentviewcontroller:weathcontroller animated:yes completion:^{ }];} B.htypedefvoid(^changinputtext) (nsstring*inputvalue); @property (copy,nonatomic) Changinputtext block;-(ibaction) Backbutton: (ID) sender; @property (weak, nonatomic) Iboutlet Uitextfield*INPUTTEXT;B.M-(ibaction) Backbutton: (ID) sender {nsstring* backsvalue=Self.inputText.text; _block (Backsvalue); [Self Dismissviewcontrolleranimated:yes completion:^{ }];} Of course, you can also use a public method, and then call the Block Wei parameter directly, you can access the following URL: http://blog.csdn.net/itpeng523/article/details/24315541
23: Single-instance mode application
. H@interface coding_netapimanager:nsobject (instancetype) Sharedmanager;- (void) Request_tweet_dotweet_withobj: (Tweet *) Tweet Andblock: (void(^) (ID data, Nserror *error)) Block; @end. m@implementation Coding_netapimanager+(instancetype) Sharedmanager {StaticCoding_netapimanager *shared_manager =Nil; Staticdispatch_once_t pred; Dispatch_once (&pred, ^{Shared_manager=[[Self alloc] init]; }); returnShared_manager;} (void) Request_tweet_dotweet_withobj: (Tweet *) Tweet Andblock: (void(^) (ID data, Nserror *error)) block{....} @end then called when: [[Coding_netapimanager Sharedmanager] request_tweet_dotweet_withobj:nexttweet andblock:^ (ID data, Nserror *error) { }];
24: Common Constants
#defineKkeywindow [UIApplication Sharedapplication].keywindow#definekscreen_bounds [UIScreen mainscreen].bounds#definekscreen_height [UIScreen mainscreen].bounds.size.height#defineKscreen_width [UIScreen mainscreen].bounds.size.widthCommon methods:- (void) Sety: (cgfloat) y{CGRect frame=Self.frame; FRAME.ORIGIN.Y=y; Self.frame=frame;}- (void) SetX: (cgfloat) x{CGRect frame=Self.frame; Frame.origin.x=x; Self.frame=frame;}- (void) SetHeight: (cgfloat) height{CGRect frame=Self.frame; Frame.size.height=height; Self.frame=frame;}- (void) SetWidth: (cgfloat) width{CGRect frame=Self.frame; Frame.size.width=width; Self.frame=frame;}- (void) SetSize: (cgsize) size{CGRect frame=Self.frame; Frame.size.width=Size.width; Frame.size.height=Size.Height; Self.frame=frame;}+(cgrect) framewithoutnavtab{CGRect frame=Kscreen_bounds; Frame.size.height-= ( -+ -+ the);//minus the height of the status bar, navigation bar, tab bar returnframe;}+(cgrect) framewithoutnav{CGRect frame=Kscreen_bounds; Frame.size.height-= ( -+ -);//minus the status bar, the height of the navigation bar returnframe;}
iOS Client Coding Project record (iii)