我使用stringInChain方法但没有看到变化

时间:2015-09-16 12:24:37

标签: ios swift

我使用StringInChain方法为属性文本,以便每次出现" hello"被改变,而不仅仅是第一次出现。我没有看到任何改变,任何问候进入,XCode告诉我没有错。有人有什么想法吗?

class ViewController: UIViewController, UITextViewDelegate{

    @IBOutlet weak var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()

        self.textView.delegate = self

        // Do any additional setup after loading the view, typically from a nib.

        let baseString = textView.text
        let attrText = baseString.chain { (string) -> Void in
            string.match("hello").withColor(UIColor.magentaColor()).withFont(UIFont(name: "Avenir", size: 30.0)!)
            //string.match("In").underline(1, andColor: UIColor.yellowColor())
            //string.match("Chain").withStroke(1, andColor: UIColor.blackColor())
        }

        textView.attributedText = attrText.attrString


    }

0 个答案:

没有答案