我正在创建 UIViewController 的子类,当用户按下按钮时,它将启动并添加另一个 UIViewController 子类的 View 。
在添加的 View 中,我有一个 UIWebView 和 UIButton 实例(用于关闭弹出窗口)。
由于它是作为弹出窗口,我想向 UIWebView 添加边框和阴影,但由于它是 nib 启动的,所以我不知道如何修改绘图代码。
有什么帮助吗? :)
最佳答案
看看如何使用 View 的 CALayer
。
添加边框:
myView.layer.borderWidth = 1.f;
myView.layer.borderColor = [UIColor blackColor].CGColor;
添加阴影有类似的方法:
myView.layer.shadowColor = [UIColor blackColor].CGColor;
myView.layer.shadowOffset = CGSizeMake(4.f, 4.f);
myView.layer.shadowRadius = 4.f;
myView.layer.shadowOpacity = 0.5f;
myView.layer.shouldRasterize = YES;
您需要将 Quartz 框架添加到您的目标,并将 header 导入 Controller 的 .m 文件中:
#import <QuartzCore/QuartzCore.h>
关于ios - 向 Nib 启动的 View 添加边框和阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17746554/