UILabel *noticeLabel = [[UILabel alloc]init];
noticeLabel.text = @"当前账号已失效果,已清除当前账号已失效果,已清除当前账号已失效果,已清除当前账号已失效果,已清除当前账号已失效果,已清除当前账号已失效果,已清除";
noticeLabel.frame = CGRectMake(0, 400, 300, 60);
noticeLabel.textColor = [UIColor whiteColor];
[self.view addSubview:noticeLabel];
noticeLabel.backgroundColor = [UIColor grayColor];
noticeLabel.numberOfLines = 0;//表示label可以多行显示
noticeLabel.lineBreakMode = NSLineBreakByClipping;
CGSize size = [noticeLabel sizeThatFits:CGSizeMake(noticeLabel.frame.size.width, MAXFLOAT)];
noticeLabel.frame =CGRectMake(10, 400, 300, size.height);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:4.0];
[UIView setAnimationDelegate:self];
noticeLabel.alpha = 0.0;
[UIView commitAnimations];
本文介绍如何使用UILabel在iOS应用中创建动态文本提示,包括设置文本、颜色、背景、多行显示及通过UIView动画实现淡入效果的过程。
618

被折叠的 条评论
为什么被折叠?



