我只想轻松打印出 myButton 尺寸。请检查代码:
@interface ViewController : UIViewController
@property (nonatomic, strong) IBOutlet UIButton *myButton;
和 .m 文件:
@implementation ViewController
@synthesize myButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect f2 = self.myButton.bounds;
printf("x: %f\n", f2.origin.x);
CGSize f3 = self.myButton.frame.size;
printf("x: %f\n", f3.height);
}
- (void)viewWillAppear:(BOOL)animated {
CGRect f2 = self.myButton.bounds;
printf("x: %f\n", f2.origin.x);
CGSize f3 = self.myButton.bounds.size;
printf("x: %f\n", f3.height);
}
这是我在控制台中收到的:
x: 0.000000
x: 0.000000
x: 0.000000
x: 0.000000
你能帮我如何打印它们吗?