小编use*_*063的帖子

来自iOS的警告"不要将子视图直接添加到视觉效果视图本身"

我有一个函数,当我链接到iOS 11 SDK时,我收到一个错误:

不要将子视图直接添加到视觉效果视图本身,而是将它们添加到-contentView.

这个问题可以通过改变来解决

let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))"
Run Code Online (Sandbox Code Playgroud)

effectView = UIView()
Run Code Online (Sandbox Code Playgroud)

但效果不是这样的.我怎样才能继续使用UIVisualEffectView而不是UIView?我想保持效果.

let imagePicker = UIImagePickerController()
let messageFrame = UIView()
var activityIndicator = UIActivityIndicatorView()
var strLabel = UILabel()    
let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))

func activityIndicator(_ title: String) {  
    strLabel.removeFromSuperview()
    activityIndicator.removeFromSuperview()
    effectView.removeFromSuperview()

    strLabel = UILabel(frame: CGRect(x: 50, y: 0, width: 160, height: 46))
    strLabel.text = title
    strLabel.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.medium)
    strLabel.textColor = UIColor(white: 0.9, alpha: 0.7)

    effectView.frame = CGRect(x: (view.frame.midX …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch subview uiview ios ios11

6
推荐指数
2
解决办法
1900
查看次数

标签 统计

cocoa-touch ×1

ios ×1

ios11 ×1

subview ×1

uiview ×1