简体   繁体   中英

iOs: Programmatically change the ratio of a UILabel in Swift

I want to change programmatically the ratio of a UILabel to have something adapted between devices (iPhone 4, 5, 6, iPad), because I can't on the StoryBoard:

在此处输入图片说明

    if DeviceType.IS_IPHONE_4_OR_LESS {
    } else if DeviceType.IS_IPHONE_5 {
    } else if DeviceType.IS_IPHONE_6 {
    } else if DeviceType.IS_IPHONE_6P {
    } else if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
    }

The multiplier property (the ratio) is readonly. You should add support for size classes in your constraints by pressing the + sign beside the Installed check box. Thus, you can specify different constraints for different size classes.

在此处输入图片说明

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