1

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

UIButton * pInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

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

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

[self.view addSubview:pInfoButton];

请告诉我如何增加它的大小,提前谢谢

4

4 回答 4

2

使用 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];
于 2013-10-25T05:48:22.800 回答
1

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

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

于 2013-10-25T05:51:23.970 回答
0

我试过你的代码,对我来说效果很好,检查附加的图像

在这里,您使用 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];
于 2013-10-25T05:39:38.130 回答
0

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

于 2013-10-25T05:49:29.263 回答