uiedgeinsets
How to set content inset for UITextView in ios
got answer: [atextView setTextContainerInset:UIEdgeInsetsMake(7, 7, 0, 0)]; fixed my problem. And in Swift… @IBOutlet var tv:UITextView! override func awakeFromNib() { super.awakeFromNib() tv.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } UPDATE: another option to do that. UIView *spacerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; [msgtext setLeftViewMode:UITextFieldViewModeAlways]; [msgtext setLeftView:spacerView];
Can I adjust a CGRect with a UIEdgeInsets?
TL;DR Swift 4.2 use theRect.inset(by: theInsets). Objective c use UIEdgeInsetsInsetRect(theRect, theInsets) Example // CGRectMake takes: left, bottom, width, height. const CGRect originalRect = CGRectMake(0, 0, 100, 50); // UIEdgeInsetsMake takes: top, left, bottom, right. const UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, -20, -20); // Apply the insets… const CGRect adjustedRect = UIEdgeInsetsInsetRect(originalRect, insets); // What’s the … Read more
How does UIEdgeInsetsMake work?
According to the documentation: You use this method to add cap insets to an image or to change the existing cap insets of an image. In both cases, you get back a new image and the original image remains untouched. During scaling or resizing of the image, areas covered by a cap are not scaled … Read more