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

后端 未结 6 2170
长发绾君心
长发绾君心 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:22

    If u want to display more than 1000 lines of text then its better to use UITextView instead of Uilabel. you can use the following code for UITextView

    UITextView *commentsTextLabel = [[UITextView alloc] init];
        commentsTextLabel.frame=CGRectMake(20, 20, 280,100);
        commentsTextLabel.text = story;
        commentsTextLabel.editable=NO;
        commentsTextLabel.scrollEnabled=YES;
        //commentsTextLabel.numberOfLines=1;
        commentsTextLabel.textColor = [UIColor blackColor];
        //[commentsTextLabel setBackgroundColor:[UIColor clearColor]];
        //[commentsTextLabel setFont:[UIFont systemFontOfSize:17]];
        commentsTextLabel.font=[UIFont systemFontOfSize:17];
        commentsTextLabel.backgroundColor=[UIColor clearColor];
        [self.view addSubview:commentsTextLabel];
    

    hope this will help you.

提交回复
热议问题