سؤال

i have tried the below code , but size of button is remains same

UIButton * pInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

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

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

[self.view addSubview:pInfoButton];

please tell me how to increase it's size , thanks in advance

هل كانت مفيدة؟

المحلول 2

You can increase it applying CGAffineTransform to the button: pInfoButton.transform = CGAffineTransformMakeScale(1.2, 1.2);. But in this case you'll lose a quality.

Another solution is to create custom button with background.

نصائح أخرى

use the UIButtonTypeCustom and set the image of the button as that of the info.

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];

I tried your code and it worked fine for me, Check attached image

Here You have use m_pInfoButton to add button [self.view addSubview:m_pInfoButton], replace code with [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];

No, you can not do change the size of Information Button, just create a custom UIButton with information icon to replace it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top