UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];[button setTranslatesAutoresizingMaskIntoConstraints:NO];[button setTitle:@"action" forState:UIControlStateNormal];[self.view addSubview:button];NSLayoutConstraint *btnCon=[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:[button superview] attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-20.0];NSLayoutConstraint *btnCon2=[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:[button superview] attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-20.0];[self.view addConstraint:btnCon2];[self.view addConstraint:btnCon];
2013年3月31日星期日
Auto Layout Demo code
订阅:
博文评论 (Atom)
没有评论:
发表评论