[英]How to design UIButton Like UITabBarItem in iOS?
I have to place 6 buttons in the bottom of particular screens like UITabBar
. 我必须在
UITabBar
等特定屏幕的底部放置6个按钮。 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. 我已将
UIButton
放置在图像和文本中,但是无法将图像移动到按钮顶部并且中心对齐,并将按钮文本放在图像下方,中心对齐。 It should be look like UITabBarItem
. 它应该看起来像
UITabBarItem
。
How can I achieve this in UIButton
? 我怎样才能在
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. 提前致谢。
you have to make 2 special image
which contains symbol
and text
. 你必须制作2个包含
symbol
和text
特殊image
。 one image is white image and second one is any color
of image . 一个图像是白色图像,第二个图像是图像的任何
color
。 and when user press button
set background
image as your color
image and set initial image
as white color
image
. 当用户按下
button
设置background
图片为您的color
图像,并设置初始image
为白色color
image
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.