How to use PartiallyEditField and features – ios

Are you looking for some things like that slack login field behavior. In slack when you entering sub domain , only subdomain will be change. but domain name (“slack.com”) will not change. it means thats non editable. It means edit will be available partially.

see the following gif to get the idea.

slackloginfield

Okay now you have clear idea…

If you want to implement that you add label for non editable text and add uitextfield for editable text.
BUT
that’s not good practice and, to develop by your self take some times. So now you have an options. thats PartiallyEditField.

PartiallyEditField library will help to you.

PartiallyEditField.gif

How to use ?

Requirements

This need uikit that’s only thing you need.

How to apply to Xcode project

Downloading Source Code
Download PartiallyEditField from gitHub
Add required frameworks

1
import "PartiallyEditField.h"

to your source code file
Using CocoaPods

1
pod "PartiallyEditField"

If you are new to CocoaPods, please go to Wiki page.

constant sample for left side

1
[_leftPreTxtField setupWithPreText:@".slack.com" color:[UIColor redColor]];

constant sample for right side

1
2
[_rightPreTxtField setupWithPreText:@"www." color:[UIColor redColor]];
_rightPreTxtField.preTextSide = kLeft;

IF you want to change placeholder color that one also available for this library.

1
_rightPreTxtField.placeHolderColor = [UIcolor blueColor];

That’s it.

The good things still you can access UITextField method and features. Because that’s inherit from UITextField

You can select side for the non editable text

1
_rightPreTxtField.preTextSide = kLeft;

It’s défault for kLight (for right side)

What are the concerns
For now you cann’t add attributed text for non editable text. Actually i have developed that feature also but got one issue when I implement it. I will add that feature in future. Currently its developing stage.

The issue was When user delete may text when it blank (when place holder display) all the text boxes touch events will be gone.

Write a Reply or Comment

Your email address will not be published.