There’s UIButton, button1 for example. I want to set its frame in the code.
I tried button1.frame = CGRectMake(20,20,50,50); but I’ve seen no effect. And I try to output the width in an alert:
alert.message = [NSString stringWithFormat:@"%f", button1.frame.size.width], and the value is 0.
I don’t know why.
There’s UIButton, button1 for example. I want to set its frame in the code.
Share
Your
UIButtonis most probably not connected in the Interface Builder if it’s an outlet or you haven’t added it as a subview if you’ve created it programmatically. Also a small tip. UseNSStringFromCGRect()to see your element’s frame parameter in detail.