Text not displaying on UILabel when the text is too large.

后端 未结 6 2155
长发绾君心
长发绾君心 2020-12-19 04:36

I have a text (Story of a book). I am taking UILabel to display it. But it is not showing me on view. I am using the following code:

    CGSize labelsize;
           


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 05:28

        CGSize labelsize;
        UILabel *commentsTextLabel = [[UILabel alloc] init];;
        [commentsTextLabel setNumberOfLines:0];
        commentsTextLabel.textColor = [UIColor blackColor];
        commentsTextLabel.text = @"The sediment-free enrichment (3) was cultivated anaerobically either in a mineral medium as described previously (19) with yeastextract (0.5%) as a carbon source or in autoclaved (1218C for 40 min) spentenrichment culture medium adjusted to pH 8.3 with sterile anaerobic 2 N NaOH.The spent culture medium was obtained by centrifugation (with anaerobic centrifuge tubes) of the enrichment culture grown in 0.5% yeast extract medium.The pH was kept within 8.0 to 8.5 by adjustment with anaerobic sterile 2 NNaOH. D. dehalogenans JW/IU-DC1 was grown in the base medium describedpreviously (19) supplemented as indicated in the text at 378C and pH 7.5.";
        [commentsTextLabel setBackgroundColor:[UIColor clearColor]];
        [commentsTextLabel setFont:[UIFont fontWithName:@"ACaslonPro-Regular"size:17]];
        labelsize=[commentsTextLabel.text sizeWithFont:commentsTextLabel.font constrainedToSize:CGSizeMake(280, 15000) lineBreakMode:UILineBreakModeWordWrap];
        commentsTextLabel.frame=CGRectMake(20, 200, 280, labelsize.height);
            [self.view addSubview:commentsTextLabel];
    

提交回复
热议问题