//
|
// UserCalloutView.swift
|
// QuanKeTong
|
//
|
// Created by alvin_y on 2019/6/13.
|
// Copyright © 2019 yang-wang. All rights reserved.
|
//
|
|
import UIKit
|
|
class UserCalloutView: UIView {
|
|
@IBOutlet weak var view_bg: UIView!
|
|
@IBOutlet weak var lb_name: UILabel!
|
|
|
/// 着色
|
var yy_tintColor = UIColor.color(hexString: "#333333")
|
|
/// 字体
|
var yy_font = UIFont.systemFont(ofSize: 12)
|
|
/// 着色
|
var yy_isTintColor = false
|
|
/// 赋值标题
|
var title: String = ""{
|
didSet{
|
if yy_isTintColor{
|
let mutableString = NSMutableAttributedString.init()
|
// 判断是否是数字
|
for item in title{
|
let pred = NSPredicate(format: "SELF MATCHES %@", "[0-9:]*")
|
if pred.evaluate(with: item.string){
|
mutableString.append(NSAttributedString.init(string: item.string, attributes: [NSAttributedString.Key.foregroundColor: yy_tintColor,NSAttributedString.Key.font: yy_font]))
|
}else{
|
mutableString.append(NSAttributedString.init(string: item.string, attributes: [NSAttributedString.Key.font: yy_font]))
|
}
|
self.lb_name.attributedText = mutableString
|
}
|
}else{
|
self.lb_name.text = title
|
self.lb_name.font = yy_font
|
}
|
}
|
}
|
|
class func instance() -> UserCalloutView {
|
let v = UINib(nibName: "UserCalloutView", bundle: nil).instantiate(withOwner: self, options: nil).first as! UserCalloutView
|
return v
|
}
|
|
}
|