为 UIWebView 和 UITextView 添加阴影
我有一个并排的 UITextView 和 WebView,我想为两者添加阴影。这是一个 iPad 应用程序,因此它们会旋转,因此它们下面的 ImageView 可能无法工作。有什么想法吗?
I have a UITextView and a WebView side by side and I would like to add a drop shadow to both. This is an iPad app, so they rotate, thus an ImageView under them probably would not work. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
UIViews 有 CALayers,它有一些内置的阴影支持。尝试一下这些属性:
这可能会很快满足您的需要。您可能需要 #import让编译器了解发生了什么。
UIViews have CALayers, that have some built-in shadow support. Try these properties out:
That may get you what you need pretty quickly. You might need to #import <QuartzCore/QuartzCore.h> to get the compiler to understand what's going on.
解决方案就像这样,
但这仅适用于 OS 3.2 及更高版本。
the solution would be like
but this just works for OS 3.2 and up.
这是快速版本:
Here is swift version:
我会添加一个位于文本字段后面的视图,并对其应用阴影效果。这样阴影就不会随着内容移动。
I would add a view that sits behind the text field, and apply the shadow effects to that. This way the shadow does not move with the content.