简体   繁体   中英

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

屏幕截图1

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
    }



}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM