简体   繁体   中英

auto adjusting the positions and height width of UILabel in iOS

I have designed my help page for my application,it contains some FAQs..so I have used UILabels for question and answer,I have adjusted,x,y,width and height exactly in the xib,leaving a gap between a question and answer and answer and next question.so totally I have some 10 question and answers,I have put them inside a scroll view.

But now, suppose the text changes dynamically, how can I adjust the positions and width and height,is a problem which I am not able to figure out, by using the below code,it adjusts the height and width of a particular label,if the text increases

NSString * test=@" It may come as a rude shock, but Facebook users should not feel surprised if tomorrow they come across their photos existing in the web world despite having deleted them personally long ago.";
    m_testLabel.text = test;
   m_testLabel.numberOfLines = 0; //will wrap text in new line
    [m_testLabel sizeToFit];

but then, my next label will clash with it..is their any way so that all the labels get adjusted according if the width of any label increases or decreases?

Hope you all have understood my question..

您是否研究了以下功能,传递了您使用过的字体以及要将标签约束到的尺寸。

- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM