문제

This sounds simple, maybe I am missing something. I have four labels that I am using in a bar graph style. I want to change the height when the button is pressed to change the height of the label and make the bar graph look properly.

In my header for the labels I have:

@property (weak, nonatomic) IBOutlet UILabel *transBar;

I have been trying to use the following line of code in the method for the button action:

//Update the height of the bar graphs.

self.transBar.frame = CGRectMake(133, 283, 100, 200); //200 will be replaced with a variable when working.

When I test this I can not get the height to change despite how simple this seems. On the XIB in the size inspector I can easily change the value from 400 to 200 and it moves exactly how I want. I just can not get this to happen in runtime. Any help appreciated. Thanks guys.

도움이 되었습니까?

해결책

How do you set the label on storyboard, are you using autolayout?

try that, let's see:

self.transBar.frame.size.height=200;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top