How to add placeholder text on border line on uitextfield edit - ios

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

Related

How do I make my UIButton title have some padding?

Let's say I have a UIButton with a size of 120 wide by 30 high. I set an attributed title on it with centered text and I set a background color on the text of the attributed text for the .highlighted state.
When the user highlights the button, I want the background that shows around the title to have the same frame as the button.
I've tried positive and negative values for the button's titleEdgeInsets and contentEdgeInsets with no luck. Any suggestions here? Thanks
The easiest (meaning most controllable) way in my opinion is to use a button subclass and override titleRect. It's called when highlighted and when unhighlighted so you get a chance to change your answer depending on the state.
However, that won't change the size of the background color of attributed text, because it applies only to the text. You'd need to change the background color of the title label itself.

Stop cursor in a UITextField or UITextView from blinking

Is it possible to stop the cursor in a UITextView or UITextField from blinking??
What I want is that the cursor should have a visible color (say blue or any other) but it should be non-blinking.
You can create an invisible text field and make it the first responder. Once you're done, you can set the first responder back to the original text field and remove the invisible text field
You can try to set the colour of Tint to clear, its a hack but works :/
textfield.tintColor = UIColor.Clear

Set the background of UILabel to transparent black

I have a UILabel that whose background I want to set to black with alpha component so that this label can have a transparent black background.
In the storyboard when I set the background to the colour I want with an alpha component even the text of the label that is in white colour becomes lighter with the alpha component.
To overcome this problem I embedded the label in a UIView and even then the same problem persists.
How can I overcome this problem. Any help will be appreciated.
You can Do only With label make IBObject an write following line.
label.backgroundColor = UIColor.black.withAlphaComponent(0.4)
Instead of changing the alpha value, change the opacity of the label background color in storyboard.
For better understanding, I have taken an imageView and placed a label at the bottom of imageView and changed the background color of the label and textColor to white. At this stage you can't see the image behind the label.
Now, go to attributes inspector and select the label background color. There you can see the opacity and change it's value. Here I have made it 50%, you can change it to whatever you want between 0 to 100 until you get your desired transparency.
create the UIview with black background color and add the UIlabel inside the view and set the alpha to 0.5 of view . finally you get the black transparent, for e.g
if you need the label text in bold change the view hierarchy
place the UILabel fist then add the UIView.
Place the UILabelabove the UIView, not inside it.
Assume that we are talking about v1 the view that contains your label , if v1 is over another view that has bright colors then when your v1's alpha get lower your label white text color will become harder to see , the text color has nothing to do with the background alpha component , so you need to reconsider using the white color or the alpha component background or the view that is behind v1 make it darker that's all we can say

UI Text Field Design

So, I was trying to mimic a video that uses sketch to design a login screen I really like. I had a question about how I can make a text field in Xcode look like the one that is being designed in the video.
Here is the video link: https://www.youtube.com/watch?v=gA_hFHkhqFM&t=87s
Here is a picture of the text field I want to design:
Any help is appreciated!
This is how to do it in the storyboard
Find/Create a blurry image and set it as an image view's image. Fill the view with the image view and add constraints. Add a new text field on top of the image view. Set these things:
border style to none
Text color to white
Background color to a black color with an alpha value and tint color to white as well.
This can be set by using the RGB slider in the color picker. Use the slider at the very bottom to adjust the alpha:
The easiest way to do it is to add a UIView with a black background. Set its alpha to 0.7.
Then add a UITextField on top. Set its border style to none, then the background color to clear.
You're done!

Add padding to left margin of UITextField in swift

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 .

Resources