Peter Pik Peter Pik - 1 year ago 98
iOS Question

Center UIButton with image next to it

I'm trying to create a UIButton where the facebook icon is a part of the centering, however i can't seem to figure out how to make it part of the centering process. So far i've just created a UIButton with the text. I could just create a image next to it, however then it will not be part of the centering.

enter image description here

Answer Source

You can easily set image and title both for your button for different control state like normal,selected or highlighted etc.

So, set your image and title to your button from storyboard or programmatically there is no need to take separate imageview for image.

You can set edge insets for title and image both from interface builder or programmatically. you can manage top or bottom edge insets for title and image of button to manage it's vertical appearance!

check screen shot below,

enter image description here

Update : (as asked in comment)

For example,

enter image description here

this is the setup for my back button with image!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download