I want to rotate a UIBarButtonItem
.
I have been able to do this with UIButton
s using setTransform:CGAffineTransformMakeRotation(…)
I extended UIToolBar, giving access to its subviews, and in it have a function rotate that rotates the buttons in the opposite direction of the bar:
- (void)rotate: (int)degrees{
//for the bar
self.transform=CGAffineTransformMakeRotation(DegreesToRadian(degrees));
//for the subviews (UIBarButtonItems)
for (UIView * subView in self.subviews)
{
if(!CGRectEqualToRect(subView.bounds, self.bounds))
subView.transform = CGAffineTransformMakeRotation(DegreesToRadian(-degrees));
}
}