我想使用TTTAttributedLabel檢測UITableViewCell標籤中的文本鏈接,但它不起作用。我在iOS8上使用swift。下面是UITableViewCell的代碼:TTTAttributedLabel鏈接檢測在iOS8中無法使用swift
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
}
}
}
查看:http://stackoverflow.com/a/22395136/1106035 – 2014-10-22 04:28:27
@Pince它不工作 – JeremyWei 2014-10-22 07:43:19