UITextView - setting font not working with iOS 6 on XCode 5

后端 未结 12 1707
旧时难觅i
旧时难觅i 2020-11-27 16:14

I\'m using storyboards for my UI. I was previously using XCode 4.6 and released on iOS 6. I have since updated to iOS 7 using XCode 5 and updated the Storyboard to work nice

相关标签:
12条回答
  • 2020-11-27 16:17

    For me it's work if you set the text of your UITextView and after set the font (same for color) :

    _myTextView.text = @"text";
    [_myTextView setFont:[UIFont fontWithName:@"Helvetica Neue" size:18.0f]];
    _myTextView.textColor = [UIColor whiteColor];
    
    0 讨论(0)
  • 2020-11-27 16:19

    As mentioned by others:

    textView.font = UIFont.systemFont(ofSize: 16)
    textView.isEditable = false
    

    p.s. no need to first set isEditable as true since it's true by default: a little shorter, a little nicer

    0 讨论(0)
  • 2020-11-27 16:22

    Thank you for all the answers guys. Issue is still present on iOS9. What i've found out, is that when you set "User Interaction Enabled = false" in the Interface Builder you can leave Editable and Selectable = true and user will not be able to edit a text view.

    So, my solution is:

    1. Set User Interaction Enabled = False in IB
    2. Set Editable = True in IB
    3. Set Selectable = True in IB
    4. Configure your text view in whatever way you want.
    0 讨论(0)
  • 2020-11-27 16:24

    I found the font size was being ignored. This was resolved by ticking the checkbox called: Selectable (having selected the UITextView within the storyboard)

    0 讨论(0)
  • 2020-11-27 16:24

    In my case, I solved by setting the new font in "viewDidLayoutSubviews".

    0 讨论(0)
  • 2020-11-27 16:31

    In my case, it is matter of 'selectable' property of UITextView.

    So I checked 'selectable' property of UITextView in Storyboard Editor to set it YES To set selectable

    and later in viewWillAppear set this property to NO.

    textview.text = @"some text";
    textview.selectable = NO;
    
    0 讨论(0)
提交回复
热议问题