UIView阴影,角半径不起作用 [英] UIView shadow, cornerradius not working

查看:49
本文介绍了UIView阴影,角半径不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  @IBOutlet弱var选择器SemiView:UIView!@IBOutlet弱var blurEffect:UIVisualEffectView!@IBOutlet var externalAreaRecognizer:UITapGestureRecognizer!覆盖func viewDidLoad(){super.viewDidLoad()selectorSemiView.layer.cornerRadius = 15selectorSemiView.layer.shadowColor = UIColor.gray.cgColorselectorSemiView.layer.shadowOffset = CGSize.zeroselectorSemiView.layer.shadowRadius = 7} 

selectorSemiView是容器视图

运行此应用程序时,没有阴影,也没有圆角.

我的代码有什么问题?

解决方案

您的代码很好,但是您忘记设置不透明度,如果您需要更多信息,则可以在

@IBOutlet weak var selectorSemiView: UIView!
@IBOutlet weak var blurEffect: UIVisualEffectView!
@IBOutlet var outerAreaRecognizer: UITapGestureRecognizer!
override func viewDidLoad() {
    super.viewDidLoad()
    selectorSemiView.layer.cornerRadius = 15
    selectorSemiView.layer.shadowColor = UIColor.gray.cgColor
    selectorSemiView.layer.shadowOffset = CGSize.zero
    selectorSemiView.layer.shadowRadius = 7

}

selectorSemiView is a container view

When I run this app, there is no shadow and no rounded corner.

What's wrong in my code?

解决方案

your code is fine but you forget to set the opacity, if you need the more information you can get the another answer in SO, for e.g

 selectorSemiView.layer.cornerRadius = 15
    selectorSemiView.layer.shadowColor = UIColor.gray.cgColor
    selectorSemiView.layer.shadowOffset = CGSize.zero  
    selectorSemiView.layer.shadowOpacity = 1.0
    selectorSemiView.layer.shadowRadius = 7.0
    selectorSemiView.layer.masksToBounds =  false

output

这篇关于UIView阴影,角半径不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆