UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 366.5f)];
UILabel *label = [[UILabel alloc] init];
CGSize s = [Content sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(310, 1000) ];//求文本的大小
label.font =[UIFont systemFontOfSize:14];//不能少这句话,与上边的字大小一致
int cnt= s.height;
label.frame =CGRectMake(5, 5, s.width, s.height);//这里要计算出label的frame大小,能够完全显示所有字符。
label.text =Content;
label.numberOfLines = 0;
label.backgroundColor =[UIColor clearColor];
scrollView.contentSize = label.frame.size;//这里赋值label的frame大小,以支持滚动浏览。
[scrollView addSubview:label];
[self.view addSubview:scrollView];
UILabel文本太长,需要滑动效果
最新推荐文章于 2018-05-26 10:22:36 发布