首页 > 其他 > 详细

传入一个label或者button,传入5s,6和6+的文字尺寸 快速定义文字大小

时间:2016-03-08 13:32:03      阅读:192      评论:0      收藏:0      [点我收藏+]
func isIphone6() -> Bool {
    
    if screenWidth() > 320 {
        
        return true
    }
    else {
        return false
    }
}

func isIphone6Plus() -> Bool {
    
    if screenWidth() > 375 {
        
        return true
    }
    return false
}

func fontSize(aView: UIView, fivs: CGFloat, six: CGFloat, sixPlus: CGFloat) {
    
    if (aView as? UILabel) != nil {
        
        
        if isIphone6Plus() {
            (aView as UILabel).font = UIFont.systemFontOfSize(sixPlus)
        }
        else if isIphone6() {
            (aView as UILabel).font = UIFont.systemFontOfSize(six)
        }
        else {
            (aView as UILabel).font = UIFont.systemFontOfSize(fivs)
        }
    }
    else if (aView as? UIButton) != nil {
        if isIphone6Plus() {
            (aView as UIButton).titleLabel!.font = UIFont.systemFontOfSize(sixPlus)
        }
        else if isIphone6() {
            (aView as UIButton).titleLabel!.font = UIFont.systemFontOfSize(six)
        }
        else {
            (aView as UIButton).titleLabel!.font = UIFont.systemFontOfSize(fivs)
        }
    }
}

 

传入一个label或者button,传入5s,6和6+的文字尺寸 快速定义文字大小

原文:http://www.cnblogs.com/Ganggang888/p/5253603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!