1.设置UITextView背景图片,在UITextView区域内.
UITextView *textView = [[UITextView alloc] initWithFrame: CGRectMake(100,100,200,100)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[textView bounds]];
imageView.image = [UIImage imageNamed:@"background"];
[textView addSubview:imageView];
[textView sendSubviewToBack:imageView];
2.设置居中
textView.textAlignment = NSTextAlignmentCenter
3.给UITextView绘制圆角,通过QuartzCore框架,操作CALayer可以给UITextView绘制圆角边框
textView.layer.cornerRadius = 5;//设置圆角弧度。
textView.layer.masksToBounds = YES;
4.设置textview的边框和边框颜色
textView.layer.borderWidth = 0.5;
textView.backgroundColor = [UIColor whiteColor];
本文介绍了如何利用QuartzCore框架为UITextView设置背景图片,实现文字居中显示,以及创建带有圆角和自定义颜色边框的效果。
221

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



