UITextView的创建/背景图片/边框和颜色/圆角等

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];

你可能感兴趣的:(iOS代码块)