swift3.0实现图片旋转任意角度
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 extension UIButton{
func Rotate(degrees:Float){
let degree=degrees * .pi/180
self.transform = CGAffineTransform(rotationAngle: CGFloat(degree))
}
}
func addNewbtn(_ x:Int,_ y:Int,_ width:Int,_ height:Int,_ pic:String)->UIButton{
let btn=UIButton()
btn.setImage(UIImage(named:pic), for: [])
btn.frame=CGRect(x:x,y:y,width:width,height:height)
return btn
}
var btn=addNewbtn(20, 100, 40, 40, "mypic.png")
btn.Rotate(degrees: 45)
嗨、骚年、快来消灭0回复。