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: