[英]Xcode 7 : set top constraint for CollectionView for iPhone 6S plus
I want to set different constraints based on device type. 我想根据设备类型设置不同的约束。 The constraint is to be set b/w CollectionView and Label (Username)
约束将在黑白视图和标签(用户名)下设置
For eg. 例如。
iPhone 4 will have top: 2 left: 0 right: 0 and bottom:0
whereas iPhone 6S Plus will have top: 15 left: 0 right: 0 and bottom:0
而
iPhone 6S Plus will have top: 15 left: 0 right: 0 and bottom:0
How can this be set in Storyboard? 如何在情节提要中设置?
you can create an outlet for the top constraint and change the value in code 您可以为顶部约束条件创建出口,并更改代码中的值
@property (weak, nonatomic) IBOutlet NSLayoutConstraint
*collectionViewTopSpaceConstraint;
-(void)viewDidLoad
{
[super viewDidLoad];
//iPhone 6 plus
if(CGRectGetHeight(self.view.frame) == 736.0)
{
self.collectionViewTopSpaceConstraint.constant = 10; // some constant
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.