uiedgeinsets

Can I adjust a CGRect with a UIEdgeInsets?

假装没事ソ 提交于 2019-11-28 06:12:16
I've got a CGRect , and I'd like to adjust it with a UIEdgeInsets . It seems like perhaps there might be a built in function that does this. I've looked for a CGRectAdjustByInsets or functions with some other CGRect… prefix, but I didn't find anything. Should I code my own? 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,

Align button image to right edge of UIButton

一笑奈何 提交于 2019-11-28 05:00:00
There are plenty of threads about aligning a button image according to the title text, but I can't find anything about just aligning the image to the right side of the button. This has no effect: button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 50); How can one right-align the image for a button? Can it be done in the Storyboard? Semantic: Force Right-to-Left on View works for me Storyboard : Attributes Tab > Ensure your Content Edge tab is selected for 'image': Then you alter the 'Left' property not right, which is what your doing programatically. So in other words, your padding it n from

How does UIEdgeInsetsMake work?

被刻印的时光 ゝ 提交于 2019-11-28 03:22:47
I'm making an app where I use UIEdgeInsetsMake for resizableImageWithCapInsets , but I don't understand how does it works exactly, UIEdgeInsetsMake has 4 arguments: Top Left Bottom Right But they're floats so I don't know how to set that to an image, thanks! :D AliSoftware 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 or resized. Instead, the pixel

Can I adjust a CGRect with a UIEdgeInsets?

帅比萌擦擦* 提交于 2019-11-27 19:17:39
问题 I've got a CGRect , and I'd like to adjust it with a UIEdgeInsets . It seems like perhaps there might be a built in function that does this. I've looked for a CGRectAdjustByInsets or functions with some other CGRect… prefix, but I didn't find anything. Should I code my own? 回答1: 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,

How to set content inset for UITextView in ios

守給你的承諾、 提交于 2019-11-27 15:31:07
问题 I'm having a UITextView and set content inset as [atextView setContentInset:UIEdgeInsetsMake(0, 10, 0, 0)]; This code working in iOS 6.1 and below, but nothing happens in iOS 7.0. 回答1: 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

Align button image to right edge of UIButton

妖精的绣舞 提交于 2019-11-27 05:28:38
问题 There are plenty of threads about aligning a button image according to the title text, but I can't find anything about just aligning the image to the right side of the button. This has no effect: button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 50); How can one right-align the image for a button? Can it be done in the Storyboard? 回答1: Semantic: Force Right-to-Left on View works for me 回答2: Storyboard : Attributes Tab > Ensure your Content Edge tab is selected for 'image': Then you alter the

How does UIEdgeInsetsMake work?

醉酒当歌 提交于 2019-11-27 00:01:36
问题 I'm making an app where I use UIEdgeInsetsMake for resizableImageWithCapInsets , but I don't understand how does it works exactly, UIEdgeInsetsMake has 4 arguments: Top Left Bottom Right But they're floats so I don't know how to set that to an image, thanks! :D 回答1: 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