how can I use one storyboard for 4“ and 3.5” iphone screens with autolayout (ios6 + ios7)?

后端 未结 4 1127
情歌与酒
情歌与酒 2020-12-23 15:04

While there are many questions and answers about building a storyboard layout that would work both on 4\" and 3.5\" screen sizes, I couldn\'t find a suitable solution for th

4条回答
  •  爱一瞬间的悲伤
    2020-12-23 15:24

    This stackoverflow answer has solved the same problem for me.

    Key is make an IBOutlet to the constraint (e.g height). Then do something like this

    - (void)updateViewConstraints {
        [super updateViewConstraints];
    
        self.myConstraintFromIB.constant =
            [UIScreen mainScreen].bounds.size.height > 480.0f ? 200 : 100;
    }
    

提交回复
热议问题