Basic knowledge of IOS development-fragment 24, basic knowledge of ios-Fragment
1: compatible with the font size 6 plue and the following differences
#define FONT_COMPATIBLE_SCREEN_OFFSET(_fontSize_) [UIFont systemFontOfSize:(_fontSize_ *([UIScreen mainScreen].scale) / 2)]
In iPhone 4 ~ In 6, the scaling factor scale = 2; in iPhone 6 +, the scaling factor scale = 3
Application:
myLabel.font=FONT_COMPATIBLE_SCREEN_OFFSET(15);
Extension: Draw a pixel macro
#define SINGLE_LINE_WIDTH (1 / [UIScreen mainScreen].scale)#define SINGLE_LINE_ADJUST_OFFSET ((1 / [UIScreen mainScreen].scale) / 2)
Application:
CGFloat xPos = 5; UIView *view = [[UIView alloc] initWithFrame:CGrect(x - SINGLE_LINE_ADJUST_OFFSET, 0, SINGLE_LINE_WIDTH, 100)];
2: The APP virtual machine can run. This problem is reported during debugging on the real machine because the product name is set to Chinese.
App installation failedThere was an internal API error. Build the Packaging Product Name in Settings to Chinese
3: Xcode certificate storage path
Resource Library/MobileDevice/Provisioning Profiles
4: If you want to hide the bottom Tab of the third-party RDVTabBarController and turn off the animation, there will be no flash.
// Hide the bottom menu-(void) viewWillAppear :( BOOL) animated {[super viewWillAppear: animated]; [[self rdv_tabBarController] setTabBarHidden: YES animated: NO];}-(void) viewWillDisappear :( BOOL) animated {[super viewWillDisappear: animated]; [[self rdv_tabBarController] setTabBarHidden: NO animated: NO];}
5. Some other Masonry content
A: make. Similar to or make. greaterthanorsimilar to (at most) or make. lessThanOrEqualTo (at least)
make.left.greaterThanOrEqualTo(label);make.left.greaterThanOrEqualTo(label.mas_left);//width >= 200 && width <= 400make.width.greaterThanOrEqualTo(@200);make.width.lessThanOrEqualTo(@400)
B: What is the difference between mascript to and similar to: mascript to has more type conversion operations than similar to. Generally, the two methods are common, but mas_equalTo is used for numerical elements. Use intent to process objects or multiple attributes. In particular, when multiple attributes are used, you must use
C: simple assignment
// make top = superview.top + 5, left = superview.left + 10,// bottom = superview.bottom - 15, right = superview.right - 20make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20))// make width and height greater than or equal to titleLabelmake.size.greaterThanOrEqualTo(titleLabel)// make width = superview.width + 100, height = superview.height - 50make.size.equalTo(superview).sizeOffset(CGSizeMake(100, -50))// make centerX = superview.centerX - 5, centerY = superview.centerY + 10make.center.equalTo(superview).centerOffset(CGPointMake(-5, 10))
D: and keyword usage
make.left.right.and.bottom.equalTo(superview); make.top.equalTo(otherView);
E: priority; priority (. priority,. priorityHigh,. priorityMedium,. priorityLow)
'. Priority 'Allow you to specify an exact priority '. priorityHigh 'is equivalent to UILayoutPriorityDefaultHigh '. priorityMedium 'between High and Low '. priorityLow is equivalent to uilayoutprioritydefalow low instance: make. left. greaterthanorpointer to (label. mas_left ). with. priorityLow (); make. top. similar to (label. mas_top ). with. priority (600 );
G: after creating a constraint using mas_makeConstraints, you can use local variables or attributes to save it for reference next time. If you create multiple constraints, you can use arrays to save them.
// Locally or globally @ property (nonatomic, strong) MASConstraint * topConstraint; // create a constraint and assign a value to [view1 mas_makeConstraints: ^ (MASConstraintMaker * make) {self. topConstraint = make. top. similar to (superview. mas_top ). with. offset (padding. top); make. left. similar to (superview. mas_left ). with. offset (padding. left) ;}]; // you can directly access self later. topConstraint [self. topConstraint uninstall];
H: mas_updateConstraints update constraints. Sometimes you need to update constraint (for example, animation and debugging) instead of creating a fixed constraint. You can use the mas_updateConstraints method.
-(Void) updateConstraints {[self. growingButton mas_updateConstraints: ^ (MASConstraintMaker * make) {make. center. similar to (self); make. width. similar to (@ (self. buttonSize. width )). priorityLow (); make. height. similar to (@ (self. buttonSize. height )). priorityLow (); make. width. lessthanorpointer to (self); make. height. lessthanorpolicto (self) ;}]; // call the parent updateConstraints [super updateConstraints];}
I: mas_remakeConstraints update constraints. mas_remakeConstraints is similar to mas_updateConstraints and both update constraint. However, mas_remakeConstraints deletes the previous constraint and then adds a new constraint (applicable to mobile animation). mas_updateConstraints only updates the constraint value.
- (void)changeButtonPosition { [self.button mas_remakeConstraints:^(MASConstraintMaker *make) { make.size.equalTo(self.buttonSize); if (topLeft) { make.top.and.left.offset(10); } else { make.bottom.and.right.offset(-10); } }];}