我使用以下代码来设置 View Controller 的 View 掩码:
view.mask = UIView(frame: view.frame)
view.mask?.backgroundColor = UIColor.black.withAlphaComponent(0.25)
view.isUserInteractionEnabled = false
然后我还使用以下代码来设置上面 View 的scrollView subview 的掩码:
scrollView.mask = UIView(frame: scrollView.frame)
scrollView.mask?.backgroundColor = UIColor.black.withAlphaComponent(0.25)
scrollView.isUserInteractionEnabled = false
蒙版显示完全不同( View 的蒙版比 ScrollView 的蒙版暗得多。有人知道为什么会发生这种情况吗?
最佳答案
在上面的问题中,您使用的是默认添加的view
,但是如果您想在导出的scrollView中应用掩码,那么您需要添加addsubview
像我在下面实现的方法,试试这个
scrollview.mask = UIView(frame: scrollview.frame)
scrollview.mask?.backgroundColor = UIColor.black.withAlphaComponent(0.25)
scrollview.isUserInteractionEnabled = false
scrollview.addSubview(scrollview.mask!)
关于ios - 设置 View Controller 的 View 属性和该 View 的 TableView subview 的掩码会导致两个看起来不同的掩码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56229847/