I have a UITextView and it has a weird margin at the top, not sure what's causing this. Here's the picture, the background is orange:
Here's my relevant 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 the text in UITextView (textViewTest) to not have any space from the top (margin). Currently, there's like 8-10 px from the top of the orange, then the text starts.
If you only want to move the text, try
[textViewTest setContentInset:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)];
Where a positive number moves the frame towards the middle, a negative moves it out from the middle.
For example, [textViewTest setContentInset:UIEdgeInsetsMake(-5, 0, 5,0)]
, will move the text 5 pixels up!
In viewDidLoad add:
self.automaticallyAdjustsScrollViewInsets = NO;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With