Code Monkey home page Code Monkey logo

acfloatingtextfield's People

Contributors

axtel209 avatar binaypg avatar dav3harry avatar erabhishekchandani avatar heliovieirasilvajr avatar keshavvishwkarma avatar mauker avatar omarbizreh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acfloatingtextfield's Issues

Display text bluer when we reset text

i have added code in viewDidLoad

let aTextField.frame = CGRect(x:20, y:300, width:UIScreen.main.bounds.width-40, height:45)
aTextField.delegate = self
aTextField.text = "hello"
aTextField.placeholder = "Password"
aTextField.errorText = "error"
self.view.addSubview(aTextField)

clear text to my custom logic like this way
aTextField.text = ""
then is display blur

screen shot 2017-04-14 at 4 04 21 pm

IB Designables Error

Hi,
I'm Facing the bellow issue when i need to edit my view i can't see the ACFloating Text fields due to the IB Designalbes rederring issue.

error: IB Designables: Failed to render and update auto layout status for myViewController (VQr-Y8-dMK): dlopen(ACFloatingTextfield_Objc.framework, 1): no suitable image found.  Did find:
	ACFloatingTextfield_Objc.framework: required code signature missing for 'ACFloatingTextfield_Objc.framework'

Please help

Place holder Issue

When I open a new page , where i kept acfloatingtextfield with some value , placeholder is not coming. When i again open then only it is visible. can you kindly check this.

Thanks in advance

leftView and rightView??

Hello!
I'm use the OC version. If I add leftView or rightView for ACFloatingTextfield, the text will be overlay with the leftView or rightView.

Textfield shows blank text

Hi,
Excellent component, however if i manually set the text values like self.txtfloatval.text = @"Something"; the text disappears sometimes in the textfield. if i tap on the field the text appears. Just called [self layoutSubviews]; after [self floatTheLabel]; in the setText function which seem to solve the issue.

lineColor's color can't changeable at first initialization

Hi,
I didn't have this situation while working on xCode 8 and iOS 10 devices. But its strangely occurs on xCode 9.
Could you look at it please?

I had to change the line;

/// Change Bottom Line Color.
- //@IBInspectable open var lineColor : UIColor = UIColor.black
+ @IBInspectable open var lineColor : UIColor?

Placeholder text Cuts

when we use place holder text with Alphabet G:- Like Height , The below part of the Placeholder text cuts.
Attached is the screenshot
screen shot 2017-09-11 at 12 45 31 am

I found some bugs in your Swift code, figured I would let you know

I manually added the ACFloatingTextField.swift file. I am thinking it was written in Swift 1 because my project uses Swift 2 and some of the issues were just changing the name of a function call. However there were some issues with some of your if statement and even though there is a field for errorTextColor your code was pointing the the placeholder color. Below is the code with the updates I made.

//
// ACFloatingTextfield.swift
// ACFloatingTextField
//
// Created by Er Abhishek Chandani on 31/07/16.
// Copyright © 2016 Abhishek. All rights reserved.
//

import UIKit

@IBDesignable
class ACFloatingTextfield: UITextField {

 var bottomLineView : UIView?
 var labelPlaceholder : UILabel?
 var labelErrorPlaceholder : UILabel?
 var showingError : Bool = false

 @IBInspectable var disableFloatingLabel : Bool = false

 @IBInspectable var lineColor : UIColor = UIColor.blackColor()

 @IBInspectable var selectedLineColor : UIColor = UIColor(red: 19/256.0, green: 141/256.0, blue: 117/256.0, alpha: 1.0)

 @IBInspectable var placeHolderColor : UIColor = UIColor.lightGrayColor()

 @IBInspectable var selectedPlaceHolderColor : UIColor = UIColor(red: 19/256.0, green: 141/256.0, blue: 117/256.0, alpha: 1.0)

@IBInspectable var errorTextColor : UIColor = UIColor.redColor()

@IBInspectable var errorLineColor : UIColor = UIColor.redColor()


//MARK:- Set Text
override var text:String?  {
    didSet {
        floatTheLabel()
        checkForDefaulLabel()
    }
}

override var placeholder: String? {
    willSet {
        self.labelPlaceholder?.text = newValue
    }
}

var errorText : String? {
    willSet {
        self.labelErrorPlaceholder?.text = newValue
    }
}

//MARK:- UITtextfield Draw Method Override
override func drawRect(rect: CGRect) {
    
    super.drawRect(rect)
    self.updateTextField(CGRect(x:self.frame.minX, y:self.frame.minY, width:rect.width, height:rect.height));

}

// MARK:- Loading From NIB
override func awakeFromNib() {
    
    super.awakeFromNib()
     self.initialize()
}

// MARK:- Intialization
override init(frame: CGRect) {
    
    super.init(frame: frame)
    self.initialize()

}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!
    self.initialize()
}

// MARK:- Text Rect Management
override func textRectForBounds(bounds: CGRect) -> CGRect {
    if (showingError) {
        return CGRect(x:0, y:0, width:bounds.size.width, height:bounds.size.height);
    }else{
        return CGRect(x:4, y:4, width:bounds.size.width, height:bounds.size.height);
    }
}

override func editingRectForBounds(bounds: CGRect) -> CGRect {
    if (showingError) {
        return CGRect(x:0, y:0, width:bounds.size.width, height:bounds.size.height);
    }else{
        return CGRect(x:4, y:4, width:bounds.size.width, height:bounds.size.height);
    }
}

//MARK:- UITextfield Becomes First Responder
override func becomeFirstResponder() -> Bool {
    let result = super.becomeFirstResponder()
    self.textFieldDidBeginEditing()
    return result
}

//MARK:- UITextfield Resigns Responder
override func resignFirstResponder() -> Bool {
    let result =  super.resignFirstResponder()
    self.textFieldDidEndEditing()
    return result
}

//MARK:- Show Error Label
func showError() {
    showingError = true;
    self.updateTextField(self.frame)
    self.showErrorPlaceHolder();
}

func showErrorWithText(errorText : String) {
    self.errorText = errorText;
    showingError = true;
    self.updateTextField(self.frame)
    self.showErrorPlaceHolder();
}

}

extension ACFloatingTextfield {

//MARK:- ACFLoating Initialzation.
func initialize() -> Void {
    
    /// HIDE DEFAULT PLACEHOLDER LABEL OF UITEXTFIELD
    checkForDefaulLabel()
    
    /// Adding Bottom Line
    addBottomLine()
    
    /// Placeholder Label Configuration.
    addFloatingLabel()
    
    /// Adding Error Label
    if (showingError) {
        if (self.errorText == "" || self.errorText == nil) {
            self.errorText = "Error";
        }
        self.addErrorPlaceholderLabel()
    }

    /// Checking Floatibility
    if self.text != nil && self.text != "" {
        self.floatTheLabel()
    }
    
}

//MARK:- ADD Bottom Line
func addBottomLine(){
    
    bottomLineView?.removeFromSuperview()
    
    //Bottom Line UIView Configuration.
    bottomLineView = UIView(frame: CGRect(x:0, y:self.frame.height-1, width:self.frame.width, height:2))
    bottomLineView?.backgroundColor = lineColor;
    bottomLineView?.tag = 20;
    
    if bottomLineView != nil {
        self.addSubview(bottomLineView!)
    }
    
}

//MARK:- ADD Floating Label
func addFloatingLabel(){
    
    labelPlaceholder?.removeFromSuperview()
    
    var placeholderText : String? = labelPlaceholder?.text
    if self.placeholder != nil && self.placeholder != "" {
        placeholderText = self.placeholder!
    }
    
    labelPlaceholder = UILabel(frame: CGRect(x:5, y:0, width:self.frame.size.width-5, height:self.frame.height))
    labelPlaceholder?.text = placeholderText
    labelPlaceholder?.textAlignment = self.textAlignment
    labelPlaceholder?.textColor = placeHolderColor
    labelPlaceholder?.font = self.font
    labelPlaceholder?.tag = 21
    
    if labelPlaceholder != nil {
        self.addSubview(labelPlaceholder!)
    }
    
}

func addErrorPlaceholderLabel() -> Void {
    
    self.endEditing(true)
    labelErrorPlaceholder?.removeFromSuperview()
    
    labelErrorPlaceholder = UILabel(frame: CGRect(x:5, y:0, width:self.frame.size.width-5, height:self.frame.height))
    labelErrorPlaceholder?.text = self.errorText
    labelErrorPlaceholder?.textAlignment = self.textAlignment
    labelErrorPlaceholder?.textColor = errorTextColor
    labelErrorPlaceholder?.font = UIFont(name: (self.font?.fontName ?? "helvetica")!, size: 12)
    labelErrorPlaceholder?.tag = 21
    
    var frameError = labelErrorPlaceholder?.frame;
    frameError?.size.height = 15;
    frameError?.origin.y = self.bounds.size.height - (frameError?.size.height ?? 0)!;
    frameError?.origin.x = 0;
    
    labelErrorPlaceholder?.frame = frameError ?? CGRect.zero;
    
    if labelErrorPlaceholder != nil {
        self.addSubview(labelErrorPlaceholder!)
    }
    labelErrorPlaceholder?.hidden = true;

}

func showErrorPlaceHolder() {
    
    labelErrorPlaceholder?.hidden = false;
    
    var bottmLineFrame = bottomLineView?.frame ?? CGRect.zero;
    bottmLineFrame.origin.y = (labelErrorPlaceholder?.frame.origin.y ?? 0)! - 1;
    
    labelErrorPlaceholder?.alpha = 0;
    labelErrorPlaceholder?.frame = CGRect(x:(labelErrorPlaceholder?.frame.origin.x ?? 0)!, y:(labelErrorPlaceholder?.frame.origin.y ?? 0)!-5, width:labelErrorPlaceholder?.frame.size.width ?? 0, height:labelErrorPlaceholder?.frame.size.height ?? 0);
    
    var labelErrorFrame = labelErrorPlaceholder?.frame ?? CGRect.zero;
    labelErrorFrame.origin.y = labelErrorFrame.origin.y + 6;
    
    UIView.animateWithDuration(0.2) {
        self.bottomLineView?.frame  =  bottmLineFrame;
        self.bottomLineView?.backgroundColor = self.errorLineColor;
        self.labelErrorPlaceholder?.alpha = 1;
        self.labelErrorPlaceholder?.frame = labelErrorFrame;
    }
    
    
}

func hideErrorPlaceHolder(){
    showingError = false;
    
    var labelErrorFrame = labelErrorPlaceholder?.frame;
    labelErrorFrame?.origin.y = (labelErrorFrame?.origin.y ?? 0)! - 6;
    
    UIView.animateWithDuration(0.2) {
        self.labelErrorPlaceholder?.alpha = 0;
        self.labelErrorPlaceholder?.frame = labelErrorFrame!;
    }
    
}

// Checks The Default Placeholder Label
func checkForDefaulLabel() -> Void {
    
    var aLabelView : UIView?
    
    for aView in self.subviews {
        
        if aView is UILabel {
            
            if aView.tag != 21 {
                
                aLabelView = aView
            }
        }
    }
    
    
    if self.text == nil || self.text == "" {
        aLabelView?.hidden = true;
    }else{
        aLabelView?.hidden = false;
    }
    
}

//MARK:- Float & Resign
func floatTheLabel() -> Void {
    
    if (self.text!.isEmpty && self.isFirstResponder()) {
        
        floatPlaceHolder(true)
        
    }else if (self.text!.isEmpty && !self.isFirstResponder()) {
        
        resignPlaceholder()
        
    }else if (!self.text!.isEmpty && !self.isFirstResponder())  {
        
        floatPlaceHolder(false)
        
    }else if (!self.text!.isEmpty && self.isFirstResponder()) {
        
        floatPlaceHolder(true)
    }
    
    self.checkForDefaulLabel()
}

//MARK:- Upadate and Manage Subviews
func updateTextField(frame:CGRect) -> Void {
    self.frame = frame;
    self.initialize()
}

//MARK:- Float UITextfield Placeholder Label.
func floatPlaceHolder(selected:Bool) -> Void {
    
    
    var bottomLineFrame = bottomLineView?.frame
    bottomLineFrame?.origin.y = self.frame.height-2
    
    if disableFloatingLabel {
        labelPlaceholder?.hidden = true
        UIView.animateWithDuration(0.2, animations: {
            self.bottomLineView?.frame = bottomLineFrame!
        })
        
        return
    }
    
    var labelFrame = labelPlaceholder?.frame
    labelFrame?.size.height = 12
    
    if selected {
        
        bottomLineView?.backgroundColor = selectedLineColor
        self.labelPlaceholder?.textColor = self.selectedPlaceHolderColor;
        
    } else {
        
        bottomLineView?.backgroundColor = lineColor;
        bottomLineFrame?.origin.y = self.frame.height-1
        self.labelPlaceholder?.textColor = self.placeHolderColor;
        
    }
    
    UIView.animateWithDuration(0.2, animations: {
        
        self.labelPlaceholder?.frame = labelFrame!;
        self.labelPlaceholder?.font = UIFont(name: (self.font?.fontName)!, size: 12)
        self.bottomLineView?.frame  =  bottomLineFrame!;
    })
    
    
}

//MARK:- Resign the Placeholder
func resignPlaceholder() -> Void {
    
    var bottomLineFrame = bottomLineView?.frame
    bottomLineFrame?.origin.y = self.frame.height-1
    
    
    bottomLineView?.backgroundColor = lineColor;
    
    if disableFloatingLabel {
        labelPlaceholder?.hidden = false
        self.labelPlaceholder?.textColor = self.placeHolderColor;
        
        UIView.animateWithDuration(0.2, animations: {
            self.bottomLineView?.frame = bottomLineFrame!
        })
        
        return
    }
    
    let labelFrame = CGRect(x:5, y:0, width:self.frame.size.width-5, height:self.frame.size.height)
    
    UIView.animateWithDuration(0.2, animations: {
        self.labelPlaceholder?.frame = labelFrame;
        self.labelPlaceholder?.font = self.font
        self.labelPlaceholder?.textColor = self.placeHolderColor;
        self.bottomLineView?.frame  =  bottomLineFrame!;
    })
    
}

//MARK:- UITextField Begin Editing.
func textFieldDidBeginEditing() -> Void {
    if showingError {
        self.hideErrorPlaceHolder()
    }
    self.floatTheLabel()
    self.layoutSubviews()
}

//MARK:- UITextField Begin Editing.
func textFieldDidEndEditing() -> Void {
    self.floatTheLabel()
}

}

Also, I do not know what your intentions are for this library but if you are going to make it compatible with swift 3 I would do that as a separate file so users still using swift 2 can also use this awesome library. I know Android has this built in and it has been annoying not having a way to have that same functionality on iOS. Thanks for writing this, it was exactly what I was looking for!

Placeholder Missing for Non Visible Cells of TableViewController

I have a UITableViewController with Static Cells. These cells contain ACFloatingTextFields. I am configuring these text fields on viewDidLoad as :
textField.selectedLineColor = [self getThemeColor];
textField.lineColor = [self getThemeColor];
textField.text = @"";

The problem is that the visible cells (text fields) of UITableViewControllers display Placeholder. Non-Visible cells do not display placeholder. (Look for the attached GIFs.)

Am I missing something specific to UITableViewController? Please guide me.

I came across this issue but it looks different than my situation : #2

I am using Objective-C version.

issue_image_1
issue_image_2

Not working on iOS11

still showing the text and not the "labelPlaceholder" when the textfield becomes firstRespond on the first time.

Linker issue

screen shot 2017-04-14 at 5 16 33 pm

I'm using xcode 8.3.1 and I did pod update as well.
AcfloatingTextfield v 1.1 is installed. But when I build my code I get linking error.

Can you help me out?

Textview Support

Hi,

Thanks for this awesome library.
Can you please let me know how can I use this control in UITextView?

Regards.

Cursor issue

I am using your library and it is good. But why cursor is not available for password options. Thanks in advance

Buttom Line Height issue

Hello ,

I facing issue over line height of textBox , it is 2px i set bottomLineViewHeight constraint to 1 px in ACFloatingTextfield (hard coded), i am using storyboard , but in some pages text bottom Line height is 2px(Suppose 3 textbox 2 have line height 1 px but 1 have line height 2px) , try to find out this issue but unable to resolve it , can you guys help me what i am doing wrong. @ErAbhishekChandani @keshavvishwkarma

ACFloatingTextfield.swift.zip

IBDesignable OBJ-C

When I use in storyboards I get error for IBDesignables:

Main.storyboard: error: IB Designables: Failed to update auto layout status: Failed to load designables from path (null).

Main.storyboard: error: IB Designables: Failed to render and update auto layout status for LoginViewController (XXZ-vo-xhS): Failed to load designables from path (null)

Storyboard error

file:///Users/carlossolano/kolbi-ios/Kolbi/Kolbi/servicesStoryboard.storyboard: error: IB Designables: Failed to render and update auto layout status for AddPhoneNumbersViewController (xOd-dz-gYy): Failed to load designables from path (null)

That Error appears in storyboard after set ACFloatingTextField in class for the textField. After that, it shows the View in blank. If i set again the class to UITextField, it works again.
captura de pantalla 2018-01-15 a la s 10 17 39

use init ACFloatingTextfield don`t set frame buttomLine is not Normal work

this is my code , the buttomLine and line Color not normal work
_pwdTextField = [[ACFloatingTextField alloc]init];
[_pwdTextField setPlaceholder:@"密码"];
_pwdTextField.tintColor = [UIColor colorWithRed:0.979 green:0.326 blue:0.380 alpha:1];
[_pwdTextField setBackgroundColor:[UIColor whiteColor]];
_pwdTextField.secureTextEntry = YES;
_pwdTextField.selectedLineColor = [UIColor colorWithHexString:@"#999999"];
_pwdTextField.selectedPlaceHolderColor = [UIColor colorWithHexString:@"#CCCCCC"];
_pwdTextField.placeHolderColor = [UIColor colorWithHexString:@"#CCCCCC"];
_pwdTextField.lineColor = [UIColor colorWithHexString:@"#E5E5E5"];
}

the buttomLine frame Y is 0 , is not self height - 1, and i set LineColor but is not use , you dont code setLineColor , init ButtomLine is init function, so ,i dont know _lineColor is block color,you can reset setLineColor function. the is last version

Issue with placeholder?

I am using ACFloatingTextfield to float the placeholder.
I have set the placeholder color programmatically and by storyboard inspector also.
But it is changing it after the selection.
It is not setting up the color while the view is loaded.
Please tell me why is this happening?

Thanks
Jittender (iOS Developer)

Setting attributedText with multiple fonts does not work

Hello, Abhishek,

First of all thanks for making such a nice library. But I am having trouble setting multiple custom fonts to the attributedText property of this control. Example is given below.

Example -
Result I want = Hello World
Result now = Hello World

Currently whatever font style I apply it always take the later font in this case the font of "World" is set to the whole string. There is no issue with creating NSAttributedString because I am using the same string in UILabel and it works fine.

Please if you have a quick fix let me know.

Thanks,

all side border

hi, its not an actually an issue, but could you help me point out where i need to modify if i want to put all side border? (not just bottom line)

thanks

Error message at the bottom of textField

Hi,
Is it possible to show error message at the bottom of TextField and not inside text field itself? I'm getting error like this:
image

Would really like to show the error message below red line.
Thanks

POD not found

When I want to install this via Cocoapods I get the error:

[!] Unable to find a specification for ACFloatingTextfield

Probably meaning the pod can't be found. When looking for it on cocoapods.org I see no typos are made, so there must some issue with how you guys handle the pods I guess...

line width

It would be great if there is a option for reducing the width of line

Placeholder

Hi. I have found a recent issue i.e when I use your texfield for Iphone 7 plus, the placeholder is not going upside. Only for iphone 7 plus.

Missing Cursor and Placeholder

I am using 'ACFloatingTextfield-Swift' latest version (1.7), and sometimes when I load a View Controller, the placeholder is missing, then if I start typing it appears. And sometimes the cursor is missing while editing.

_placeholderLabel. issue

[<ACFloatingTextField 0x7fbec4e057d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _placeholderLabel.'

appearance?

styling via appearance so we don't need to do it one by one

thanks

Reset to default state after error message

Hi, thanks for this great library.
I have issue to reset the default state after showing an error like this:
self.showErrorTextField(textField, message: "Username not available")
textField.errorTextColor = UIColor.red
How i get back to default state, for example gray when I want to begin editing? Without have to change focus to other text field first.

Thanks

pod?

how to use it with pod?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.