Customize UIBarbuttonitem with Background Images

前端 未结 4 644
心在旅途
心在旅途 2021-02-01 11:46

I have added an instance of UIToolbar and buttons on top of it . Each button\'s belongs to the class of UIBarButtonItem.

My Requirement is that each button has a customi

4条回答
  •  广开言路
    2021-02-01 11:50

    The problem here is, that UIBarButtonItem is not a UIView-Subclass. I had the same problem too and the solution is quite trivial:

    Create a UIButton Object with your custom background image, afterwards create an instance of a UIBarButtonItem using its initWithCustomView: method and passing your UIButton object as a parameter.

    Hope I could help you.

提交回复
热议问题