CGAffineTransformMakeRotation scale down my image

177 Views Asked by At

I am using CGAffineTransformMakeRotation to rotate my button.But my button getting scaled(big or small) according to my value to rotate.How to stop scaling of my button? sample code i have used

 UIView.animateWithDuration(2.5, animations: {
        self.btnMeter.transform = CGAffineTransformRotate(CGAffineTransformIdentity, (45 * CGFloat(M_PI)) / 180.0) 

    })
2

There are 2 best solutions below

0
Madhumitha On BEST ANSWER

I have kept my button on UIView.After that I have rotated my view using the same code.It works fine.

0
techloverr On

try this

UIView.animateWithDuration(2.5, animations: {
    btnMeter.transform = CGAffineTransformRotate(btnMeter.transform, (45 * CGFloat(M_PI)) / 180.0)

})

and put this in viewdidAppear instead of viewDidLoad