我正在使用Swift 2.3分支code。
我有一个UICollectionViewCell
我在单元格内使用ActiveLabel
。 Label有#,url的回调。所以在url点击后,我启动一个模态View Controller。在取消View Controller后,标签上同时包含了url&单元格内的#呈现它,然后#的文字消失!
collectionViewCell
中的标签:
class CustomViewCell : UICollectionViewCell {
lazy var messageLabel : ActiveLabel = {
let label = ActiveLabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont(name: SWFontNames.regularFont, size: SWFontSize.medium)
label.numberOfLines = 0
label.lineSpacing = 4
label.lineBreakMode = NSLineBreakMode.ByWordWrapping
label.textColor = UIColor.whiteColor()
label.hashtagColor = UIColor().rgb(90, green: 200, blue: 250)
label.mentionColor = UIColor(red: 238.0/255, green: 85.0/255, blue: 96.0/255, alpha: 1)
label.URLColor = UIColor(red: 85.0/255, green: 238.0/255, blue: 151.0/255, alpha: 1)
label.URLSelectedColor = UIColor(red: 82.0/255, green: 190.0/255, blue: 41.0/255, alpha: 1)
return label
}()
override init(frame:CGRect) {
super.init(frame:frame)
// Do auto layout
}
}
EDIT1:Cell
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let customcell = collectionView.dequeueReusableCellWithReuseIdentifier(cellId, forIndexPath: indexPath) as! CustomViewCell
let feedData = profileFeed[indexPath.item]
customcell.messageLabel.text = feedData.commentContent
return customCell
}
测试案例:
Input String: https://www.youtube.com #dealWith yes > after reload > https://www.youtube.com
Input String: https://www.yahoo.com > https://
Input String: hi #deal #done > remains same, hi #deal #done