繁体   English   中英

如何增加UIButtonTypeInfoLight的大小

[英]how to increase the size of UIButtonTypeInfoLight

我尝试了下面的代码,但按钮的大小保持不变

UIButton * pInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

[pInfoButton setFrame:CGRectMake(100,100, 80, 80)];

[pInfoButton setBounds:CGRectMake(0, 0, 80, 80)];

[self.view addSubview:pInfoButton];

请告诉我如何增加它的尺寸,提前谢谢

使用UIButtonTypeCustom并将按钮的图像设置为信息的图像。

UIButton*infoButton=[[UIButton buttonWithType:UIButtonTypeCustom];
infoButton.frame=CGRectMake(100,100, 80, 80); 
[infoButton setImage:[UIImage imageNamed:@"info_btn.png"] forState:UIControlStateNormal];
[self.view addSubview:infoButton];

您可以通过将CGAffineTransform应用于按钮来增加它: pInfoButton.transform = CGAffineTransformMakeScale(1.2, 1.2); 但在这种情况下,你会失去一个品质。

另一种解决方案是创建带背景的自定义按钮。

我试过你的代码,它对我很好, 检查附图

这里你使用m_pInfoButton添加按钮[self.view addSubview:m_pInfoButton],用[self.view addSubview:pInfoButton]替换代码。

UIButton * pInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[pInfoButton setFrame:CGRectMake(100,100, 80, 80)];
[pInfoButton setBounds:CGRectMake(0, 0, 80, 80)];
[self.view addSubview:pInfoButton];

不,你不能改变Information Button的大小,只需创建一个带有信息图标的自定义UIButton来替换它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM