Add padding to left margin of UITextField in swift - ios

I have a UITextField with a background image set. The background image consists of a border with an icon on the left side. I'd like to move the cursor so the editing starts after the icon appears. How would I accomplish this in swift?
edit: Would it be easier have a custom border as an uimageview and the textfield placed over it and attached to it? If so what would be the best way to do this?

if you want left padding in TextField just use below code ,
youTextFiled.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0);
The amount of left padding you can change by changing the value of at first argument .

Related

How to add placeholder text on border line on uitextfield edit

I followed this link to create placeholder animation on user text edit in UiTextField, but i need to make it place on the border of uitextfield like this
As you see in the image i need border to trim and to make visible to background gradient color , How will i do it. Thanks in advance

How to make an NSTextAttachment(image) takes whole line? iOS

In my UITextView, i just set NSMutableAttributeString an NSTextAttachment which is a UIImage. Though i have set the attachment width to the screen width,but when i tap the image, the input cursor will come into the right of my image.
but which i want is:
when insert an image via NSTextAttachment,there should be empty lines at the top and bottom of the image respectively,and the input cursor can only appear in the bottom or the top of the image rather than the left or right.

Hiding and showing UILabel with rounded corner and shadow in Swift 2

I am using this method Swift - Problems with corner radius and drop shadow to add rounded corners and shadow to a UILabel.
However, I need to hide and unhide the label depending on content. I am setting hidden true/false in my ViewController class. But the shadow layer still shows.
See example images below.
What is the best way to hide/unhide this shadow layer as well?
Set the alpha to 0:
myLabel.alpha = 0

How do I create connected text fields in ios?

I want to create a login screen similar to facebook's for my iOS app.
How do I create 2 text-fields that are both in that rounded box?
Embed two textfields in a UIView and give that view the layer.cornerRadius that you need
Giving UIView rounded corners
add 2 UITextfields and set their borders to none
add background image having rounded corner from top left and top right to the 1st uitextfield i.e. username uitextfield
add background image having rounded corner from bottom left and bottom right to the 2nd uitextfield i.e. password uitextfield
add a bordered layer (CALayer), set layer properties like, borderwidth, borderColor and frame as per your requirement and add this layer to uitextfield layer.

iPhone - Image not align at center on UIButton

I have customized UIButton with the following properties:
84x44 frame
84x44 background image
32*32 image that should be centered
but my image is always aligned to the left. How can I align it back to center position on the UIButton?
I have a title on my button that is hidden (clearColor). These titles are key_value in a dictionary so I know which button is pressed and return corresponding value in the dictionary.
I now understand that it's these text that is pushing my image sideway, but how do I fix that?
Under attribute inspector,
there is a tap named Edge, set to Image.
I set left value as 22
and all image align to center.
Can someone explain to me how this works?
Check that your titleLabel is blank - if it has text, it will push the image to the left to make room for the titleLabel on the right.

Resources