, я хотел бы дать пользователю возможность выбрать размер кнопки в соответствии с выбором пользователя ... Могу ли я сделать это, пожалуйста?
mytweak.xm
UIButton *respringButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
respringButton.frame = CGRectMake(self.view.frame.size.width - 250, self.view.frame.size.height / 2 - 80, 60, 60);
[respringButton setImage:[UIImage imageWithContentsOfFile: respring] forState:UIControlStateNormal];
[respringButton setTitle:@"respring" forState:UIControlStateNormal];
[respringButton addTarget:self action:@selector(reboot) forControlEvents:UIControlEventTouchUpInside];
if(style != 1) {
respringButton.tintColor = tintColor;
} else {
if(defaultTheme1 == 0) {
respringButton.frame = CGRectMake(self.view.frame.size.width - 250, self.view.frame.size.height , 60, 60);
} else if (defaultTheme1 == 1) {
respringButton.frame = CGRectMake(self.view.frame.size.width - 250, self.view.frame.size.height , 80, 80);
} else if (defaultTheme1 == 2) {
respringButton.frame = CGRectMake(self.view.frame.size.width - 250, self.view.frame.size.height , 100, 100);
}
}
[respringButton centerVertically];
[myView addSubview:respringButton];
mytweak.h
- (void)centerVertically {
// Spacing between the text and the image
CGFloat spacing = 5.0;
// Lower the text and push it left so it appears centered below the image
CGSize imageSize = self.imageView.frame.size;
self.titleEdgeInsets = UIEdgeInsetsMake(0.0, - imageSize.width, - (imageSize.height + spacing),- 120.0);
// Raise the image and push it right so it appears centered above the text
CGSize titleSize = self.titleLabel.frame.size;
self.imageEdgeInsets = UIEdgeInsetsMake(- (titleSize.height + spacing), 0.0, 0.0, - titleSize.width);
}
@end