简体   繁体   English

有没有一种方法可以使UITextView具有类似UITextField框的类似周围阴影?

[英]Is there a method to get a UITextView with similar surrounding shadow like a UITextField box?

There is a way to get the UITextView with the rounded corners and inner shadow-y type border identical to a UITextField ? 有一种方法可以使UITextView具有与UITextField相同的圆角和内部阴影Y型边框?

Is there a link or information out there that someone could link toward doing this? 是否有链接或信息可供某人链接以进行此操作? I assume it's going to involve subclassing UITextView and it's drawRect again? 我假设它将涉及子类化UITextView并且它又是drawRect吗?

It seems like something that people would commonly want though so I assume it's been done or solved already? 似乎人们通常希望这样做,所以我认为已经完成或解决了吗?

My solution would be to put a UIImageView under the UITextView, while giving the textview a clear background color. 我的解决方案是将UIImageView放在UITextView下,同时为textview提供清晰的背景色。 If you use the stretchableImageWithLeftCapWidth:topCapHeight: method on a screencap of a regular textfield, you could easily resize the thing and achieve nice results. 如果在常规文本字段的屏幕截图上使用stretchableImageWithLeftCapWidth:topCapHeight:方法,则可以轻松调整内容大小并获得不错的结果。 Unfortunately, I don't think there's an easier way... 不幸的是,我认为没有更简单的方法...

four rounded corners you can do 你可以做四个圆角

#import <QuartzCore/QuartzCore.h>

then in viewDidLoad 然后在viewDidLoad中

[uitextview.layer setCornerRadius:7];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM