简体   繁体   中英

Dynamic Height of UIView

I have an UIView in storyboard(0,20,320,80) with this frame. I have to show data inside it from xib and in that xib i have a label on upper side and below that label there an image, label height is dynamic and below that image should be display.Dynamic data is showing proper in label and below that image also showing but height is not increasing of that UIView those in storyboard.It's always taking 80 px. I also added "Less than or equal" or "Greater than or equal" conditions to height constraint of view but didn't get success.

This is code:-

self.dummyView.labelTitle.text = @"shfdj weu f weufyh euky h yt  yt3eg b dqwhgy uj hbdjdb ej2hy c 38iuyh  f kyjuh   yu  jugyfecb jue gb   ughy bre uikjy3fd f3uyhbn hui3fjn iuh4fejn giujknfjk hujinkfej ikujhjen ujikhrnfd iukhjk";

UIView *viewBottom = [[UIView alloc]initWithFrame:CGRectMake(0, self.dummyView.viewDataHolder.frame.origin.y+self.dummyView.viewDataHolder.frame.size.height +20, 320, 150)];

//viewBottom.backgroundColor = [UIColor blackColor];
[self.view addSubview:viewBottom];

[This is Xib that have to load]

https://i.stack.imgur.com/fI2jr.png

Got to Storyboard -> Open Inspector -> Label -> numberofLines = 0

Also, don't set greater or equal, I don't think it's necessary, give normal top , leading , trailing and bottom layout to UILabel

Set constraint top, bottom, leading, trailing for UILable with respective SuperView

lable.numberOfLines = 0
lable.lineBreakMode = .byWordWrapping

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