专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构
添加遮罩图片和布局
- 懒加载遮罩图片
/// 遮罩视图, 不要写maskView, 因为View有一个maskView属性 private lazy var coverView: UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_mask_smallicon"))
- 添加到
访客视图
- 在
prepareUI
方法中添加,需要注意遮罩视图
是在转轮上面
其他视图下面
addSubview(iconView) // 添加遮罩视图 addSubview(coverView) addSubview(homeView)
- 在
- 设置约束
// 遮盖 coverView.translatesAutoresizingMaskIntoConstraints = false // X addConstraint(NSLayoutConstraint(item: coverView, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: iconView, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0)) // Y addConstraint(NSLayoutConstraint(item: coverView, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: iconView, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0))
- 在
prepareUI
设置VistorView
背景颜色// 背景颜色 backgroundColor = UIColor(white: 237 / 255, alpha: 1)