How do I create connected text fields in ios? - 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.

Related

Can we hide a UIView partially in iOS

I have to partially hide a UIView when user scrolls over it. There is a UIScrollView above UIView.
For example in the given image below i want to hide the area covered under the scrollable area which is in blue color. All my views background colors are clear color.
I want to hide the part as given in the below image, the marked rectangle which is in red color. So that part of text (One, Two, Three) is only visible.
Each UIView, including UIScrollView, has a Core Animation Layer (a CALayer).
You access the CALayer with
view.layer
In turn, a CALayer has a mask, which you access with
layer.mask
Using the mask is the most comprehensive method of controlling visibility and opacity at runtime.

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

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 .

create custom button animation

I need to create custom button with animation. When user touches button it fills with blue shape from left to right (I have done this with CAShapeLayer and CABasicAnimation). But also while shape fills button I need to change button text color (only letters that shape already reached, from left to right).

iOS : How to create a close button that sits on the edge of a UIView with rounded corners (using IB)?

Background:
I am working on an iPad app that will pop a custom view when the user clicks on an image.
I want the view to have rounded corners and a close button ( red x in a circle ) that sits on right top edge.
The button in half inside and half outside the view.... Take a look at the Kayak or Zynga Poker apps to see what I am talking about.
Question : If I create the view programmatically and add the button, it works.
However, I really want to user a nib to create the view so I can design the view correctly. So when I call self.layer.maskToBounds = YES on the view ( to create the rounded corners with a radius of 25 ), it clips my button ( since its half in and half out ). How do I retain my button without it getting clipped and still have rounded corners ?
Sounds to me like you are using a view and a button. What you might try is using a third container view (with clear background) in which you place your original view and your button. The button will need to be on top of the view, so to speak, so it is not obscured by your view. But that should allow you to have properly rounded corners on your view (not the container view) and have your button fully visible.
Some settings, such as maskToBounds, cornerRadius, aren't available in IB. You can create the entire view using a NIB except it won't have rounded corners in IB and in viewDidLoad you set just those properties that couldn't be set in IB.

Resources