在许多iPhone应用程序中,我都能看到圆角的UITextView。有没有一种简单的方法来实现这一点?或者我需要创建一个自定义的UITextView?有没有链接到展示如何实现这一点的示例?
谢谢!
发布于 2010-08-30 08:30:50
如果您使用的是iOS 3+,则可以执行以下操作:
myTextView.clipsToBounds = YES;
myTextView.layer.cornerRadius = 10.0f;发布于 2012-05-11 21:25:02
将QuartzCore框架添加到应用程序,然后
#import <QuartzCore/QuartzCore.h>
UITextView* txtView = [[UITextView alloc] initWithFrame:CGRectMake(50, 50, 300, 100)];
txtView.layer.cornerRadius = 5.0;
txtView.clipsToBounds = YES;发布于 2016-04-29 00:35:22
只需快速提醒一下:您可以通过stroyboard/xib轻松完成此操作:

或者创建一个扩展,并以编程方式或通过故事板进行设置
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
set {
layer.cornerRadius = newValue
layer.masksToBounds = newValue > 0
}
get {
return layer.cornerRadius
}
}
}https://stackoverflow.com/questions/3596176
复制相似问题