Thursday, 24 October 2013

Dynamic set height of label

There are so many occassions when we have to set height of the label according to text displayed in label or textview etc.

NSString *text  = @"A fairy tale is a type of short story that typically features folkloric fantasy characters, such as fairiesgoblinselvestrollsdwarvesgiants,mermaids, or gnomes, and usually magic or enchantments. Fairy tales may be distinguished from other folk narratives such as legends (which generally involve belief in the veracity of the events described) and explicitly moral tales, including beast fables."

CGSize textViewSize;

textViewSize = [text sizeWithFont:[UIFont fontWithName:@"Helvetica Neue" size:14.0]
                                   constrainedToSize:CGSizeMake(246, FLT_MAX)
                                       lineBreakMode:UILineBreakModeCharacterWrap];
 [geographics_lbl setFrame:CGRectMake(x, y, 246, roundf(textViewSize.height))];

1 comment:

  1. How to use a game of roulette with the help of blackjack - Dr.MCD
    Roulette is a classic 순천 출장샵 game of 광주 출장마사지 luck with 전라남도 출장샵 a great twist. It is 이천 출장마사지 very popular in casinos around 남원 출장샵 the world. However, some people like it

    ReplyDelete