を「視覚効果ビュー自体に直接サブビューを追加しないでください」私は、以下の機能を持っていると私はiOSの11 SDKにリンクするとき、私はエラーを取得する:警告
Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.
問題があることができ
effectView = UIView()
に
let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))"
を変更することによって解決その効果はそのようには存在しません。 UIView
の代わりにUIVisualEffectView
を引き続き使用するにはどうすればよいですか?私はその効果を保ちたい。
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 - strLabel.frame.width/2), y: (view.frame.midY - strLabel.frame.height/2), width: 160, height: 46)
effectView.layer.cornerRadius = 15
effectView.layer.masksToBounds = true
activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .white)
activityIndicator.frame = CGRect(x: 0, y: 0, width: 46, height: 46)
activityIndicator.startAnimating()
effectView.addSubview(activityIndicator)
effectView.addSubview(strLabel)
view.addSubview(effectView)
}