swift 代码笔记3

1/   在系统的cell 中  可以自一个image view  覆盖到系统的 UIImageview   也可以在系统的 UIImageview  添加一个 UILable 或者 UIButton 的子控件 

 //var imgRili = UIImageView(frame: CGRectMake(0, 0, 0, 0))

        var lblrili = UILabel(frame: CGRectMake(2, 0, 30, 40))

        lblrili.font = UIFont.systemFontOfSize(12)

        lblrili.textColor = appThemeColor

        lblrili.text = "Aug"

        lblrili.textAlignment = NSTextAlignment.Center

        cell.imageView?.image = UIImage(named: "pouer_rili")

        cell.imageView?.addSubview(lblrili)

        cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator

        return cell



2/  富文本的使用 

(1) 

        var str1 = "2.1"

        var str2 : NSMutableAttributedString = NSMutableAttributedString(string:str1 + "kwh")

        let smallFont = [NSFontAttributeName:UIFont.systemFontOfSize(24)]

        let bigFont = [NSFontAttributeName:UIFont.systemFontOfSize(50)]

        str2.addAttributes(bigFont, range: NSMakeRange(0,(str1 as NSString).length))

        str2.addAttributes(smallFont, range: NSMakeRange((str1 as NSString).length,3))

        let headerTitle = UILabel(frame: CGRectMake(ScreenWidth/2,50,ScreenWidth/2,210-100))


        headerTitle.attributedText = str2

        headerView.addSubview(headerTitle)

(2)

        var strtmp = NSMutableAttributedString(string:"I agree Software License Agreement")

        let strRange = NSMakeRange(8,26)

        let addrAttr = [NSForegroundColorAttributeName:appThemeColor]

        strtmp.addAttributes(addrAttr, range: strRange)

        //strtmp.addAttribute(kCTForegroundColorAttributeName, value:appThemeColor.CGColor, range: strRange)

        let lblagree = UILabel(frame:CGRect(origin: CGPointMake(16, CGRectGetMaxY(txtPwd2.frame)+16), size: CGSize(width: self.view.frame.size.width-32, height: 14)))

        //lblagree.text = "I agree Software License Agreement"

        lblagree.attributedText = strtmp



3/  多种样式的tableviewcell 



import UIKit


class TTSmartModeViewController: UIViewController,TTInterceptorProtocol,UITableViewDataSource,UITableViewDelegate {


    enum SmartModeCellType:Int {

        case AutoPowerCellType = 1

        case AutoSleepCellType

        case TimerCellType

        case IndicatorCellType

        case LightOFFCellType

        case LightONCellType

        case LightAutoCellType

        case LightColorCellType

        

        var title:String{

            switch self {

            case AutoPowerCellType :

                return "Auto Power-on"

            case AutoSleepCellType:

                return "Auto Sleep Mode"

            case TimerCellType:

                return "Timer"

            case IndicatorCellType:

                return "Indicator Light"

            case LightOFFCellType:

                return "OFF"

            case LightONCellType:

                return "ON"

            case LightAutoCellType:

                return "Auto"

            case LightColorCellType:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值