IOS client Coding project record (3): ios client coding project

Source: Internet
Author: User

IOS client Coding project record (3): ios client coding project

18: Fill style of Image view

_ ImgView. contentMode = align; as follows: typedef NS_ENUM (NSInteger, UIViewContentMode) {comment, UIViewContentModeRedraw, // redraw on bounds change (CILS-setNeedsDisplay) UIViewContentModeCenter, // contents remain same size. positioned adjusted. UIViewContentModeTop, UIViewContentModeBotto M, UIViewContentModeLeft, UIViewContentModeRight, UIViewContentModeTopLeft, UIViewContentModeTopRight, orientation, UIViewContentModeBottomRight,}; Description: Fill: indicates that the object is fully filled in the frame. (Default) UIViewContentModeScaleAspectFit: Keep the ratio within frame. UIViewContentModeScaleAspectFill: Maintain the proportion, which is filled up but exclusive to frame. UIViewContentModeRedraw: 
 UIViewContentModeCenter: the center of the image and the center of the frame. UIViewContentModeTop: the upper edge of the image overlaps with the upper edge of frame. UIViewContentModeBottom: the lower edge of the image overlaps with the lower edge of frame. UIViewContentModeLeft: the left edge of the image overlaps with the left edge of frame. UIViewContentModeRight: the right edge of the image overlaps with the right edge of frame. UIViewContentModeTopLeft: similar. UIViewContentModeTopRight: similar. UIViewContentModeBottomLeft: similar. UIViewContentModeBottomRight: similar.

19: application of the UIView attribute clipsTobounds

Add a view and cut edges (the application of the UIView attribute clipsTobounds). For example, there are two views: view1 and view2view1. Add view2 to the view. If view2 is greater than view1, or the coordinates of view2 are not within the range of view1. view2 is covered by view1, which means that the excess part will also be drawn. UIView has an attribute. clipsTobounds is NO by default. If, if we want view2 to hide the excess part, we have to change its parent View to the clipsTobounds attribute value of view1. View1.clipsTobounds = YES;

20: CALayer common settings

Border, rounded corner, and shadow. layer. cornerRadius = 4.0f; someView. layer. masksToBounds = YES; // set the border and border color scheme someView. layer. borderWidth = 0.5f; someView. layer. borderColor = [[UIColor grayColor] CGColor]; then // Add four side shadows into _ imgvPhoto. layer. shadowColor = [UIColor blackColor]. CGColor; Specify _ imgvPhoto. layer. shadowOffset = CGSizeMake (0, 0); shadowOffset _ imgvPhoto. layer. shadowOpacity = 0.5; prop _ imgvPhoto. layer. shadowRadius = 10.0; _ imgvPhoto. layer. masksToBounds = NO; // Add two edge shadows. layer. shadowColor = [UIColor blackColor]. CGColor; Specify _ imgvPhoto. layer. shadowOffset = CGSizeMake (4, 4); shadowOffset _ imgvPhoto. layer. shadowOpacity = 0.5; prop _ imgvPhoto. layer. shadowRadius = 2.0; Description: Required ① someView indicates UIView and the like; required ②: # import <QuartzCore/QuartzCore. h>

21: UIActionSheet pop-up display

# Define kKeyWindow [UIApplication sharedApplication]. keyWindowUIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil delegate: self cancelButtonTitle: @ "cancel" structivebuttontitle: nil cancel: @ "", @ "select from album ", nil]; [actionSheet showInView: kKeyWindow];

22: use of block callback for parameter passing

Two viewcontrollers are respectively a and B. a jumps to B, obtains a value from B, jumps to a, and displays the value of B. The Code is as follows:. h-(IBAction) otherStoryboard :( id) sender; @ property (weak, nonatomic) IBOutlet UILabel * lableInfo;. m-(IBAction) otherStoryboard :( id) sender {UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName: @ "storyboard" bundle: nil]; extends viewcontroller * weathcontroller = [mainStoryboard restart: @ "storyboard"]; weathcontroller. block = ^ (NSString * InputValue) {self. lableInfo. text = InputValue;}; [self presentViewController: weathcontroller animated: YES completion: ^ {}];} B. htypedef void (^ 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, visit the following url: http://blog.csdn.net/itpeng523/article/details/24315541

23: Use of Singleton Mode

. H @ interface Coding_NetAPIManager: NSObject (instancetype) sharedManager;-(void) Publish :( Tweet *) tweet andBlock :( void (^) (id data, NSError * error) block; @ end. m @ implementation Coding_NetAPIManager + (instancetype) sharedManager {static Coding_NetAPIManager * shared_manager = nil; static dispatch_once_t pred; dispatch_once (& pred, ^ {shared_manager = [[self alloc] init];}); return Shared_manager;} (void) request_Tweet_DoTweet_WithObj :( Tweet *) tweet andBlock :( void (^) (id data, NSError * error) block {.... } @ End: [[Coding_NetAPIManager sharedManager] request_Tweet_DoTweet_WithObj: nextTweet andBlock: ^ (id data, NSError * error) {}];

24: Common Constants

# Define kKeyWindow [UIApplication sharedApplication]. keyWindow # define kScreen_Bounds [UIScreen mainScreen]. bounds # define kScreen_Height [UIScreen mainScreen]. bounds. size. height # define kScreen_Width [UIScreen mainScreen]. bounds. size. common Methods of width:-(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-= (20 + 44 + 49); // minus the return frame of the status bar, navigation bar, and Tab bar;} + (CGRect) frameWithOutNav {CGRect frame = kScreen_Bounds; frame. size. height-= (20 + 44); // minus the height of the status bar and navigation bar, return frame ;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.