objective c - iOS: UILabel text setting issue -

i have used autolayout. if text small in question number & question displaying in same line text large , question displaying in 2 lines, @ time question number displaying in between question
i have set autolayout

i want 1st question number & question on same line below image

uilabel alway centered in vertical axis.
what have calculate height of uilabel considering text given , font size using.
here bit of example:
cgrect yourrect = [[nsstring stringwithformat:@"%@", yourtexthere] boundingrectwithsize:cgsizemake(200, 40) options:nsstringdrawinguseslinefragmentorigin attributes:@{nsfontattributename: [uifont whateverfontyouuse:21]} context:nil]; self.questionidwidthconstraint.constant = yourrect.size.height + 1;
Comments
Post a Comment