I want to rotate a UIBarButtonItem
.
I have been able to do this with UIButton
s using setTransform:CGAffineTransformMakeRotation(…)
, but UIBarButtonItem
does not have this property.
I know the Camera-app does this, so it should be achieveable.
How can I achieve this?
Thanks.
You could put a UIButton inside a Bar Button Item, than rotate the UIButton.
Have you tried using a custom view inside the UIBarButtonItem that you then transform any way you want?
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:
UIBarButtonItem does not extend UIView, so it cannot be transformed directly. You can add the UIBarButtonItem you wish to transform to a UIToolbar, transform the UIToolbar and then add the toolbar as a custom view to another UIBarButtonItem. This item can then be set as a navigation item or added to another UIToolbar. However, if you are using a custom view or image then Emil's approach in the comment above is best.