Giter Site home page Giter Site logo

idhaval / dttextfield Goto Github PK

View Code? Open in Web Editor NEW
336.0 8.0 57.0 822 KB

DTTextField is a custom textfield with floating placeholder and error label

License: MIT License

Ruby 3.35% Swift 95.02% Objective-C 1.63%
swift uitextfield dttextfield error-label floating-placeholder xcode

dttextfield's People

Contributors

idhaval avatar smit9612 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

dttextfield's Issues

Issue: input mobile number only 9 digit.

can You check in your demo mobile number input.
I am adding your pod file and validate with number.

`class func verifyPhoneNumber(text : String) -> (String, Bool) {
var verifyObj = (message : "", isVerified : false)
if text.length == 0 {
verifyObj.message = vcErrorPhoneNumber

        //        } else if text.length < 10 { //< 8 { if country code option is also on screen
        //            verifyObj.message = vcErrorValidPhoneNumber
        
    }

// else if text.length > 10{
// verifyObj.message = contactMayNOtBeGreaterThan
//
// }
else if !text.isContainsAllZeros() {
verifyObj.message = vcErrorValidPhoneNumber
print("isContainsAllZeros",verifyObj)

    } else if !text.containsNumberOnly() {
        print("text mob number:- ",text)
        verifyObj.message = vcErrorValidPhoneNumber
        print("containsNumberOnly",verifyObj)

//
} else if !text.isValidMobileNumber() && text.count < 9 {
verifyObj.message = vcErrorValidPhoneNumber
print("text mob:- ",text)
print(verifyObj)

    }
    else {
        verifyObj.isVerified = true
    }
    return verifyObj
}`

`func isContainsAllZeros() -> Bool {
let mobileNoRegEx = "^0*$";
let mobileNoTest = NSPredicate(format:"SELF MATCHES %@", mobileNoRegEx)
return mobileNoTest.evaluate(with: self)
}
func containsNumberOnly() -> Bool {
let nameRegEx = "^[0-9]+$"
let nameTest = NSPredicate(format:"SELF MATCHES %@", nameRegEx)
let test = nameTest.evaluate(with: self)
print(test)
return test
}

func isValidMobileNumber() -> Bool {
let mobileNoRegEx = "^[0-9]{8,16}$"
// let mobileNoRegEx = "^\d{3}-\d{3}-\d{4}$"
// let mobileNoRegEx = "^[0-9+]{0,1}+[0-9]{5,16}$" //
// let mobileNoRegEx = "(?:(?:\+|0{0,2})91(\s*[\- ]\s*)?|[0 ]?)?[789]\d{9}|(\d[ -]?){10}\d"

    let mobileNoTest = NSPredicate(format:"SELF MATCHES %@", mobileNoRegEx)
let texts = mobileNoTest.evaluate(with: self)
print("Number",texts)
    return texts
}`

changing border style to none and customize field.

Hi,
Thanks for the awesome control. Can you please tell how can I make it border to .none and add underline? I tried changing border style to none but seems its been used inside core logic. Kindly let me know. Thanks

Regards,
Amir

textFieldShouldReturn not working

How can I implement textFieldShouldReturn when i press return button on keyboard?

func textFieldShouldReturn(textField: UITextField) -> Bool {
return true
}

Help me please. This is not calling...

DTTextField Crash

Hi!

Some users are getting this error when using DTTextField;

Crashed: com.apple.main-thread
0 DTTextField 0x104209498 specialized DTTextField.insetRectForBounds(rect : CGRect) -> CGRect (DTTextField.swift:285)
1 DTTextField 0x104206324 @objc DTTextField.textRect(forBounds : CGRect) -> CGRect + 344
2 UIKit 0x18cfec0fc -[UITextField _marginTopForBounds:] + 184
3 UIKit 0x18c428c70 -[UITextField _originForTextFieldLabel:] + 128
4 UIKit 0x18c4209f4 -[UIFieldEditor textContainerOrigin] + 212
5 UIFoundation 0x1a11c27b0 -[NSLayoutManager _primitiveInvalidateDisplayForGlyphRange:] + 2836
6 UIFoundation 0x1a11c2f34 -[NSLayoutManager invalidateDisplayForCharacterRange:] + 436
7 UIFoundation 0x1a119cbc0 -[NSLayoutManager(NSPrivate) _setExtraLineFragmentRect:usedRect:textContainer:] + 416
8 UIFoundation 0x1a11f952c -[NSTypesetter _layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:maxCharacterIndex:nextGlyphIndex:nextCharacterIndex:] + 6060
9 UIFoundation 0x1a11a0c94 -[NSATSTypesetter layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:] + 364
10 UIFoundation 0x1a11bfc28 -[NSLayoutManager setTextStorage:] + 720
11 UIFoundation 0x1a11e97a8 -[NSTextStorage addLayoutManager:] + 100
12 UIKit 0x18c755040 -[UIFieldEditor initWithTextField:textStorage:] + 752
13 UIKit 0x18c429b38 -[UITextField _fieldEditor] + 196
14 UIKit 0x18cff6700 -[UITextField _initContentView] + 60
15 UIKit 0x18cfe928c -[UITextField initWithCoder:] + 1680
16 DTTextField 0x10420898c specialized DTTextField.init(coder : NSCoder) -> DTTextField? (DTTextField.swift:166)
17 DTTextField 0x1042050e4 @objc DTTextField.init(coder : NSCoder) -> DTTextField? (DTTextField.swift)
18 UIKit 0x18c963fb4 -[UIClassSwapper initWithCoder:] + 248
19 UIKit 0x18cb01d24 UINibDecoderDecodeObjectForValue + 680
20 UIKit 0x18cb01a64 -[UINibDecoder decodeObjectForKey:] + 104
21 UIKit 0x18c963c24 -[UIRuntimeConnection initWithCoder:] + 136
22 UIKit 0x18c9643f8 -[UIRuntimeEventConnection initWithCoder:] + 68
23 UIKit 0x18cb01d24 UINibDecoderDecodeObjectForValue + 680
24 UIKit 0x18cb01e9c UINibDecoderDecodeObjectForValue + 1056
25 UIKit 0x18cb01a64 -[UINibDecoder decodeObjectForKey:] + 104
26 UIKit 0x18c962f98 -[UINib instantiateWithOwner:options:] + 1168
27 UIKit 0x18c7632cc -[UIViewController _loadViewFromNibNamed:bundle:] + 372
28 UIKit 0x18c525dd4 -[UIViewController loadView] + 176
29 UIKit 0x18c4f6ca8 -[UITableViewController loadView] + 92
30 UIKit 0x18c406dd8 -[UIViewController loadViewIfRequired] + 184
31 UIKit 0x18c4af870 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 76
32 UIKit 0x18c4aed00 -[UINavigationController _startTransition:fromViewController:toViewController:] + 196
33 UIKit 0x18c4ae6e8 -[UINavigationController _startDeferredTransitionIfNeeded:] + 876
34 UIKit 0x18c4ae254 -[UINavigationController __viewWillLayoutSubviews] + 156
35 UIKit 0x18c4ae15c -[UILayoutContainerView layoutSubviews] + 188
36 UIKit 0x18c4044f0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1224
37 QuartzCore 0x18b920a84 -[CALayer layoutSublayers] + 148
38 QuartzCore 0x18b914d70 CA::Layer::layout_if_needed(CA::Transaction*) + 296
39 QuartzCore 0x18b914c2c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
40 QuartzCore 0x18b88b88c CA::Context::commit_transaction(CA::Transaction*) + 276
41 QuartzCore 0x18b8b2ae4 CA::Transaction::commit() + 520
42 QuartzCore 0x18b8b361c CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
43 CoreFoundation 0x18558c6e4 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
44 CoreFoundation 0x18558a18c __CFRunLoopDoObservers + 412
45 CoreFoundation 0x18558a670 __CFRunLoopRun + 1076
46 CoreFoundation 0x1854a503c CFRunLoopRunSpecific + 436
47 GraphicsServices 0x195cfaf94 GSEventRunModal + 100
48 UIKit 0x18c46a86c UIApplicationMain + 208
49 0x103e7db80 main (LoginViewController.swift:16)
50 libdyld.dylib 0x1a8c37d1c start + 4

Does someone have any ideas why there's this crash?

Thanks!
W

NSForegroundColorAttributeName

we are facing issue when using pod of DTTextField. when we are trying to set "placeholder" Foreground color attribute then following compiler error occured (using xcode 9.1)

'NSForegroundColorAttributeName' was obsoleted in Swift 3 (UIKit.NSForegroundColorAttributeName)

Xcode 9 swift 4 crash iOS 11

DTTextField_Example[5003:262200] [Accessibility] ****************** Loading GAX Client Bundle ****************
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-09-21 17:44:22.977669-0500 DTTextField_Example[5003:262200] fatal error: unexpectedly found nil while unwrapping an Optional value

Underlining mode of UI

It will be nice to have ability to setup underlining instead of rounded rect background, when needed

NSAttributedStringKey doesn't work

public var placeholderColor:UIColor?{
didSet{
guard let color = placeholderColor else { return }
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
attributes: [NSAttributedStringKey.foregroundColor:color])
}
}

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

how to fix it?

error

i have to validate twice to show error.
my code to show error.
guard !textFieldPassword.text!.isEmptyStr else {
textFieldPassword.showError = true
textFieldPassword.errorMessage = emailMessage
return false
}

Example project should not require pod install (broken)

Hi Dhaval

Perhaps change the example project so that it doesn't require running pod install

I downloaded the project, but couldn't get it working out of the box. Pod install didn't work for me.

PROMPT> pod install
Analyzing dependencies
Downloading dependencies
Installing DTTextField (0.2.5)

[!] Error installing DTTextField
[!] /usr/bin/git clone https://github.com/iDhaval/DTTextField.git /var/folders/54/gf7lcj014z7558cgt81dhks40000gn/T/d20170523-92356-1cqondp --template= --single-branch --depth 1 --branch 0.2.5

Cloning into '/var/folders/54/gf7lcj014z7558cgt81dhks40000gn/T/d20170523-92356-1cqondp'...
fatal: unable to access 'https://github.com/iDhaval/DTTextField.git/': Unknown SSL protocol error in connection to github.com:-36


[!] Automatically assigning platform ios with version 9.0 on target DTTextField_Example because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
PROMPT> 

Environment

   CocoaPods : 1.2.1
        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.12.4 (16E195)
       Xcode : 8.3.1 (8E1000a)
         Git : git version 2.11.0 (Apple Git-81)
Ruby lib dir : /Users/johndoe/.rvm/rubies/ruby-2.3.0/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 8fd040a59f38bc862a98faadeb632a837cc5ef60

Problem with foregroundColor

Hello. I have a problem with the library after install XCode 10.
Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

Issue with Textfield background colour

How to change the background colour of Ui textfield , If i changed the background colour from Xcode then there is issue with the background colour of the textfield . After changing the colour it still showing white background colour. Tried Tint colour also but nothing works.

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.