小编Jer*_*Wei的帖子

TTTAttributedLabel链接检测在iOS8中使用swift无法正常工作

我想使用TTTAttributedLabel来检测UITableViewCell标签中文本的链接,但它不起作用.我正在使用iOS8的swift.下面是UITableViewCell代码:

class StoryTableViewCell: UITableViewCell, TTTAttributedLabelDelegate {
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code

        // Link properties
        let textLabel = self.descriptionLabel
        let linkColor = UIColor(red: 0.203, green: 0.329, blue: 0.835, alpha: 1)
        let linkActiveColor = UIColor.blackColor()

        if (textLabel is TTTAttributedLabel) {
            var label = textLabel as TTTAttributedLabel
            label.linkAttributes = [NSForegroundColorAttributeName : linkColor]
            label.activeLinkAttributes = [NSForegroundColorAttributeName : linkActiveColor]        
            label.enabledTextCheckingTypes = NSTextCheckingType.Link.toRaw()

            label.delegate = self
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

uitableview ios tttattributedlabel swift ios8

8
推荐指数
1
解决办法
8895
查看次数

标签 统计

ios ×1

ios8 ×1

swift ×1

tttattributedlabel ×1

uitableview ×1