0
你好,我在我的應用程序中使用SDWebImage。這是我的代碼,以使圖像中的圓圈如何圈圖像
extension UIImage {
var circle: UIImage? {
let square = CGSize(width: min(size.width, size.height), height: min(size.width, size.height))
let imageView = UIImageView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: square))
imageView.contentMode = .ScaleAspectFill
imageView.image = self
imageView.layer.cornerRadius = square.width/2
imageView.layer.masksToBounds = true
UIGraphicsBeginImageContext(imageView.bounds.size)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
imageView.layer.renderInContext(context)
let result = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return result
}
}
從here
複製它,我用來做圖像cicle這樣
let profilePicture = UIImage(data: NSData(contentsOfURL: NSURL(string:"http://i.stack.imgur.com/Xs4RX.jpg")!)!)!
profilePicture.circle
,但現在由於我使用SDWebImage它不是工作
cell.profileImageView.sd_setImageWithURL(UIImage().absoluteURL(profileImageUrl), placeholderImage: UIImage.init(named: "default-profile-icon")?.circle!)
請讓我知道我可以彌補這方面的推廣工作SDWebImage
老兄你真是太棒了。說實話,在一個小時後沒有得到答案,我以爲我永遠無法使用這個extenion。你很棒。感謝感謝超時 – hellosheikh