swift(五)

2020-10-14  本文已影响0人  温柔vs先生
        let min = 3
        let second = 4
        
        let time = String(format: "%02d:%02d", min, second)
        print(time)
// 让控件不随着父控件的拉伸而拉伸autoresizingMask
        autoresizingMask = UIViewAutoresizing()
//(一般在横竖屏切换时,自动相应布局)
// oc写法
    redView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin;
// swift 写法
        var arm1 = UIViewAutoresizing.None
        arm1.unionInPlace(UIViewAutoresizing.FlexibleRightMargin)
        arm1.unionInPlace(UIViewAutoresizing.FlexibleLeftMargin)
        arm1.unionInPlace(UIViewAutoresizing.FlexibleBottomMargin)
        arm1.unionInPlace(UIViewAutoresizing.FlexibleTopMargin)
        
        redView.autoresizingMask = arm1
// 自动相应宽高布局
// swift写法
 redView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

上一篇 下一篇

猜你喜欢

热点阅读