UITextView weird edge on top?

I have a UITextView and it has a weird edge at the top, not sure what causes this. Here is the image, the background is orange:

enter image description here

Here is my corresponding code:

textViewTest = [[UITextView alloc] initWithFrame:CGRectMake(135, 0, 150, 68)];
[textViewTest setContentInset:UIEdgeInsetsZero];
[textViewTest setUserInteractionEnabled:NO];
[textViewTest setBackgroundColor:[UIColor orangeColor]];
[textViewTest setTextColor:[UIColor whiteColor]];
//[textViewTest setFont:[UIFont fontWithName:@"MuseoSans-500" size:12.0]];
[textViewTest setText:@"Spooky (rename)\nCreated: 4/10/11\nUpload Youtube\nDelete | Favorite"];

What I want is text in a UITextView (textViewTest) so there is no space on top (margin). Currently, there, as 8-10 pixels from the top of the orange, the text begins.

+5
source share
4 answers

If you only want to move the text, try

[textViewTest setContentInset:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)];

If a positive number moves the frame toward the middle, a negative number moves it out of the middle.

For example, [textViewTest setContentInset:UIEdgeInsetsMake(-5, 0, 5,0)]move the text 5 pixels up!

+19
source

In viewDidLoad add:

 self.automaticallyAdjustsScrollViewInsets = NO;
+2
source

, : [textViewTest sizeToFit];

-1

, , . ? , .

why not use the red color view y like

textViewTest = [[UITextView alloc] initWithFrame:CGRectMake(135, 
                                                            [redView frame].origin.y,
                                                            150, 68)];
-1
source

All Articles