如何使用 SDWebImage 将 alpha 属性 添加到 UIImage 集?
How to add alpha property to an UIImage set with SDWebImage?
我在 Xcode 上使用 SDWebImage 插件处理我的图像,但我需要为其添加 alpha 效果(透明度),但它无法识别 属性。
我知道我可以为普通的 UIImage 做这样的事情,它会起作用...
posterBackground.image = UIImage(with: URL(string: movieImage!)!.alpha(0.15)
但是用 SDWebImage 插件尝试同样的方法不起作用...
posterBackground.sd_setImage(with: URL(string: movieImage!), placeholderImage: UIImage(named: "poster-placeholder"))!.alpha(0.15)
它给我错误 "Value of tuple type 'Void' has no member 'apha'"。有什么方法可以让我使用插件并将 alpha 属性 应用于图像?
提前致谢。
感谢@Happiehappie 的评论以及来自另一个 post 的 this answer,我能够应用 alpha 属性。这是最终的工作代码...
posterBackground.sd_setImage(with: URL(string: movieImage!), placeholderImage: UIImage(named: "poster-placeholder"), options: SDWebImageOptions(rawValue: 0), completed: { (image, error, cacheType, imageURL) in
self.posterBackground.image = image?.alpha(0.15)
})
我在 Xcode 上使用 SDWebImage 插件处理我的图像,但我需要为其添加 alpha 效果(透明度),但它无法识别 属性。
我知道我可以为普通的 UIImage 做这样的事情,它会起作用...
posterBackground.image = UIImage(with: URL(string: movieImage!)!.alpha(0.15)
但是用 SDWebImage 插件尝试同样的方法不起作用...
posterBackground.sd_setImage(with: URL(string: movieImage!), placeholderImage: UIImage(named: "poster-placeholder"))!.alpha(0.15)
它给我错误 "Value of tuple type 'Void' has no member 'apha'"。有什么方法可以让我使用插件并将 alpha 属性 应用于图像?
提前致谢。
感谢@Happiehappie 的评论以及来自另一个 post 的 this answer,我能够应用 alpha 属性。这是最终的工作代码...
posterBackground.sd_setImage(with: URL(string: movieImage!), placeholderImage: UIImage(named: "poster-placeholder"), options: SDWebImageOptions(rawValue: 0), completed: { (image, error, cacheType, imageURL) in
self.posterBackground.image = image?.alpha(0.15)
})