ios - label is not growing when the text is longer -


i want view centered in superview grows due content in case label. don't want grow doesn't fit in screen anymore thats why pin left , right.

i've put on test viewcontroller:

import uikit import purelayout  final class viewcontroller: uiviewcontroller {      let container: uiview = {         let container = uiview(forautolayout: ())         container.backgroundcolor = uicolor.blackcolor()         container.clipstobounds = true         return container     }()      let label: uilabel = {         let label = uilabel(forautolayout: ())         label.textalignment = nstextalignment.center         label.numberoflines = 1         label.textcolor = uicolor.redcolor()         label.text = "this very long message"         return label     }()      var rightview: uiview = {         let view = uiview(forautolayout: ())         view.backgroundcolor = .redcolor()          return view     }()      override func viewdidload() {         super.viewdidload()          self.container.addsubview(self.label)         self.view.addsubview(self.container)         self.view.addsubview(self.rightview)          self.container.autopinedgetosuperviewedge(.bottom, withinset: 20)         self.container.autoalignaxistosuperviewaxis(.vertical)         self.container.autosetdimension(.height, tosize: 36)         self.container.layer.cornerradius = 18         self.container.autopinedge(.right, toedge: .left, ofview: self.rightview, withoffset: -20, relation: .lessthanorequal)         self.container.autopinedgetosuperviewedge(.left, withinset: 20, relation: .greaterthanorequal)         self.container.setcontentcompressionresistancepriority(uilayoutpriorityrequired, foraxis: .horizontal)          self.label.autopinedgestosuperviewedgeswithinsets(uiedgeinsetsmake(10, 20, 10, 20))          self.rightview.autopinedgetosuperviewedge(.right, withinset: 5)         self.rightview.autopinedgetosuperviewedge(.bottom, withinset: 20)         self.rightview.autosetdimension(.width, tosize: 50)         self.rightview.autosetdimension(.height, tosize: 60)     } } 

the result of is:

enter image description here

why black view not growing until can't due left , right constraint? number of lines 1 , contentcompressionresistancepriority on?

what leading , trailing constraints on label, set leading constraint inequality greater or equal 5. if you're happy font smaller, set adjustsfontsizetofitwidth yes.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -