如何在swift中设置图像 [英] How to set image in circle in swift
本文介绍了如何在swift中设置图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用swift制作我的圈子图片?
How can i make i circle picture with swift ?
我的ViewController:
My ViewController :
import UIKit
import Foundation
class FriendsViewController : UIViewController{
@IBOutlet weak var profilPicture: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
profilPicture = UIImageView(frame: CGRectMake(0, 0, 100, 100))
}
}
我的 profilPicture = UIImageView(框架:CGRectMake(0, 0,100,100))
什么都不做..
例如: http://www.appcoda.com/ios-programming-circular-image-calayer/
推荐答案
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var image: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
image.layer.borderWidth = 1
image.layer.masksToBounds = false
image.layer.borderColor = UIColor.blackColor().CGColor
image.layer.cornerRadius = image.frame.height/2
image.clipsToBounds = true
}
这就是你所需要的......
That is all you need....
这篇关于如何在swift中设置图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文