首先感谢YYText这个强大的框架
最近项目有这样的text需求
整个text垂直置顶,然后前面的分类有边框并颜色要红色
不说太多,show the code
在cell中设置垂直置顶,因为这是cell中的控件
_contentLalel = [[YYLabel alloc]init];
_contentLalel.font = [UIFont systemFontOfSize:14];
_contentLalel.textVerticalAlignment = YYTextVerticalAlignmentTop;//设置垂直置顶
_contentLalel.numberOfLines = 2;
然后我是在集合视图的这里设置的边框和分类标题颜色的
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
分别设置text的普通颜色和边框、高亮的颜色和边框