Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to design UIButton Like UITabBarItem in iOS?

I have to place 6 buttons in the bottom of particular screens like UITabBar. I have placed UIButton with Image and Text but, am not able to move the image on top of the button with centre alignment and place the button text in below of the image with center alignment. It should be look like UITabBarItem.

How can I achieve this in UIButton? Anyone can please help me on this? Thanks.

I tried this code but, text not visible and image not properly aligned. Can you please help me?

[self.languageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.languageButton setTitle:@"Language" forState:UIControlStateNormal];
[self.languageButton.titleLabel setFont:[UIFont boldSystemFontOfSize:10.0]];

UIImage *image = [UIImage imageNamed:@"lang_change_white"];

[self.languageButton setTitleEdgeInsets:UIEdgeInsetsMake(0.0, -image.size.width, -25.0, 0.0)];
[self.languageButton setImage:image forState:UIControlStateNormal];
[self.languageButton setImageEdgeInsets:UIEdgeInsetsMake(-15.0, 0.0, 0.0, -self.languageButton.titleLabel.bounds.size.width)];

Thanks in advance.

enter image description here

like image 466
Yuvaraj.M Avatar asked Jan 29 '26 17:01

Yuvaraj.M


1 Answers

enter image description here

  1. your code work fine for me then what is problem ?
  2. plz explein what you want with image and text of the button..?
like image 146
Sanandiya Vipul Avatar answered Jan 31 '26 09:01

Sanandiya Vipul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!