【发布时间】:2019-09-02 14:40:32
【问题描述】:
我有一个 UIImage 视图,然后是一个叠加层,然后是另一个 UIImage 视图。我需要顶部 UIImageView 根本不透明。我不想看到任何背景图片。
我尝试设置 alpha,我尝试将混合处理器与 Kingfisher 一起使用,我尝试将 png 转换为 jpg,我尝试将一个子视图移动到另一个子视图前面,我尝试更改图像的背景颜色,我尝试将顶部图像设置为不透明而不是不透明,因为我阅读了不同的内容,我尝试了很多东西。
clientProfileImg.borderWidth = 2.0
clientProfileImg.borderColor = UIColor.white
clientProfileImg.isUserInteractionEnabled = false
clientBackgroundProfileImg.isUserInteractionEnabled = false
view.bringSubview(toFront: clientProfileImg)
view.sendSubview(toBack: clientBackgroundProfileImg)
clientProfileImg.backgroundColor = UIColor.black
clientProfileImg.alpha = 1.0
guard let profilePic = client?.profilePhoto else { print("No profile pic"); return }
let resource = ImageResource(downloadURL: URL(string: profilePic)!, cacheKey: profilePic)
// Blend (iOS)
// let processor = BlendImageProcessor(blendMode: .sourceAtop, alpha: 1.0, backgroundColor: .black)
// Set the image to Kingfisher which caches it
DispatchQueue.main.async {
self.clientProfileImg.kf.setImage(with: resource, placeholder: #imageLiteral(resourceName: "user-gray"), options: [.forceRefresh, .cacheSerializer(FormatIndicatedCacheSerializer.jpeg)])
self.clientBackgroundProfileImg.kf.setImage(with: resource, options: [.forceRefresh,
.cacheSerializer(FormatIndicatedCacheSerializer.jpeg)]
}
这是我看到的:
这就是我想要的:
【问题讨论】:
标签: ios swift uiimageview uiimage overlay