zoukankan      html  css  js  c++  java
  • Swift UILabel

            var lable = UILabel (frame: CGRectMake(10,10,200,100))
            lable.text = "yangxiaolong yangyang"
            lable.backgroundColor = UIColor .redColor()
            lable.textColor = UIColor .whiteColor()
    //        文本位置
            lable.textAlignment = NSTextAlignment.Center
    //        lable.font = UIFont(name: "Zapfino" ,size: 20)
            lable.lineBreakMode = NSLineBreakMode.ByTruncatingTail
    //        case ByWordWrapping // Wrap at word boundaries, default
    //        case ByCharWrapping // Wrap at character boundaries
    //        case ByClipping // Simply clip 直接隐藏
    //        case ByTruncatingHead // Truncate at head of line: "...wxyz" 头隐藏
    //        case ByTruncatingTail // Truncate at tail of line: "abcd..." 尾隐藏
    //        case ByTruncatingMiddle // Truncate middle of line:  "ab...yz" 中间隐藏
    //       当字数过多的时候合理缩放
    //                lable.adjustsFontSizeToFitWidth=true
            lable.numberOfLines=2

            self.view .addSubview(lable)
            var  str = "welcome swift"
            
            var attributString = NSMutableAttributedString(string: str)
            
    //       字体以及大小
            attributString.addAttribute(NSFontAttributeName, value: UIFont(name: "Zapfino" ,size: 16)!, range: NSMakeRange(0,7))
    //        
            attributString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blueColor(), range: NSMakeRange(0, 3))
            
            attributString.addAttribute(NSBackgroundColorAttributeName, value: UIColor .orangeColor(), range: NSMakeRange(0, 3))
            
            lable.attributedText = attributString

  • 相关阅读:
    linux 定时脚本任务的创建
    win10 Edge 无法上网代理服务器错误
    CentOS 7 系统root用户忘记密码的重置方法
    通过挂载系统光盘搭建本地yum仓库的方法
    Oauth服务端协议开发
    mongodb 用户权限控制
    javascript 数组方法拼接html标签
    存储管理与linux内存寻址(1)
    原型模式
    背包,队列,栈的java实现
  • 原文地址:https://www.cnblogs.com/yangxiaolong/p/5343895.html
Copyright © 2011-2022 走看看