Вопрос

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