raulriera / textfieldeffects Goto Github PK
View Code? Open in Web Editor NEWCustom UITextFields effects inspired by Codrops, built using Swift
License: MIT License
Custom UITextFields effects inspired by Codrops, built using Swift
License: MIT License
Please, provide Carthage support to make installation easier.
The Hoshi textFeild borderInactiveColor not show in Simulator
Arguably, all the properties should either be customisable or internal so they can be subclassed... Maybe?
Is there any way to add a image to the placeholder? Or at least pin a image beside it so that it follows it?
Feature request
Hi,
at first, thank you very much for that nice library!
I have a question, is it possible to setup the corner radius in Yoshiko Style?
Kind regards
Since this method is called a few times, the foregroundView and placeholderLabel will be add multiple times. I think this is not very elegant, need to consider only add them only once. Am I right?
As the title suggests, I cannot see the line underneath the Hoshi Text Field.
Code:
let textField = HoshiTextField(frame: textFieldFrame)
textField.delegate = self
textField.placeholderColor = UIColor.whiteColor()
textField.placeholder = "Email"
textField.textColor` = `UIColor.whiteColor()
Created a simple subclass
import UIKit
import TextFieldEffects
class CLHoshiTextField: HoshiTextField {
var isFieldValid = false
}
And trying to access it:
@IBOutlet var emailTextField : CLHoshiTextField!
self.emailTextField.text = "[email protected]"
Causes exc_bad_access 2. The outlet itself is not nil, and it initialized, so trying to figure out why this is hapenning...
I am getting the following errors when I tried to build the Pod on Swift version 2.1.1 and Xcode 7.2.
Expected expression in list of expressions
Expected ',' separator
The errors are on the following lines in file TextFieldEffects.swift:
fatalError("\(#function) must be overridden")
and
..addObserver(self, selector: #selector(textFieldDidEndEditing)..
This problem appears to be due to the usage of hashes (#) in the code.
Any idea what is happening?
Hi,
Is it possible to make Kaede
's textfield's background translucent? or change just its alpha?
🙌
Xcode didn't like that change if you use the source files alone
Issue is the constructor signature in UITextField. Fixed it on local version, will be sending a pull request shortly
Swift 2.0 Support
I tried to add a prefixed character as first character ("+" sign for phone numbers) as soon as clicked on the text field by using attributedText. However, it eliminated the creation animation.
To be exact:
I am adding the prefixed character in:
func textFieldDidBeginEditing(textField: UITextField) {
if textField == phoneField {
if textField.text?.characters.count < 2 {
makePrefix()
}
}
}
Is there a way to check if the animation is completed, and then add the prefixed character? What is the best place to put the creating the attributed text?
How do you use this programmatically (without storyboard)? I am unable to instantiate the KaedeTextField as there are no constructors.
This effect doesn't animate correctly, everything just "pops" without any transition at all.
Thanks for the great library!
I am trying to dismiss keyboard on click on return and on click outside. I tried using what I usually use but unfortunately, no luck:
func textFieldShouldReturn(textField: HoshiTextField) -> Bool {
self.view.endEditing(true)
return false
}
func dismissKeyboard() {
view.endEditing(true)
}
What is the proper way of dismissing the keyboard? Thanks in advance
Please add Pod support for this awesome work
When the TextField's text property is set in viewDidAppear, the "effect" is not shown, and the hint is displayed behind the actual text. The proplem don't happen when the text is set in viewDidLoad though.
I am using AkiraTextField and I am trying to
+20
to height, but bottom of the box disappears like this:private func rectForBounds(bounds: CGRect) -> CGRect {
return CGRect(x: bounds.origin.x, y: bounds.origin.y + placeholderHeight, width: bounds.size.width, height: (bounds.size.height - placeholderHeight)+20)
}
private let borderSize : (active: CGFloat, inactive: CGFloat) = (1.1, 1.1)
Are there any ways to increase the height or the borderSize? Thanks
Any chance to get this for a UITextView?
Similar to the appledoc ones
Hello,Raul
I’ m using HoshiTextField,everything works fine if I enter text from keyboard.But when I set the text of textfield manually,like textfield.text = “abcdefg”,the placeholder text does not move up, so the text being set got covered by the placeholder text.Is there any way the fix the problem?
Thanks.
As I understand you are overriding textFieldDidBeginEditing
and textFieldDidEndEditing
methods. This leads that we can't call those in viewController to do any additional work on textFields.
Could be also that I just don't know enough what's happening.
Lots of us still need to support iOS 7, is this possible with TextFieldEffects?
Thanks!
This might be a stupid question, but I can't find a function to do it.
Hi,
I'm using Cocoapods to add this project to my own, but that's causing issues when I want to make a custom subclass of TextFieldEffects since a few of the functions are declared as internal rather than public - all of the TextFieldsEffectsProtocol methods for example. I was able to bypass this by overriding the functions that were public (ex. drawRect, prepareForInterfaceBuilder) but that isn't ideal.
I was wondering if this limitation was intentional?
Thank you for the wonderful library!
At the moment just a single one of the effects is created. Need to support most if not all of them
I tried setting textField.textAlignment = .Center
however there seem to be a little bug.
At first (without typing anything) it doesn't seem centered...
But as soon as I start typing a letter, it pushes the blue line to center and actually works fine..
It's just a mini-visual bug. Everything works nicely after I start typing. Or maybe am I the one breaking it?
Hi, I got this error at run time.
I just drag the TextFieldEffects folder to my project:
and use it in my XIB:
and I got this warning:
at run time i got this error
Unknown class _TtC16TextFieldEffects14HoshiTextField in Interface Builder file.
Failed to set (borderInactiveColor) user defined inspected property on (UITextField): [<UITextField 0x12dd96030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key borderInactiveColor.
any idea :( ?
Sample project not running. Is there something that I miss?
file:///Users/stephen/iphone/Kitchen/Kitchen/Base.lproj/Main.storyboard: error: IB Designables: Failed to render instance of HoshiTextField: Rendering the view took longer than 200 ms. Your drawing code may suffer from slow performance.
Hi,
I'm trying to use appearance to customize an HoshiTextField instance.
In the AppDelegate, I call the Appearance method:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Appearance().applyStyling()
...
Which contains:
class Appearance: NSObject {
func applyStyling() {
HoshiTextField.appearance().backgroundColor = UIColor.redColor() //will work
HoshiTextField.appearance().placeholderColor = UIColor.redColor() // will fail
}
}
Doing that, I get a EXC_BAD_ACCESS in the second line of the method. Any idea why this isn't working? Is it somehow not compatible with appearance yet?
Thanks for your help and for your really cool plugin!
I really like the library and the effects, but how can I implement this in my Objective-C project (Xcode 6, iOS 8)
http://gfycat.com/ThriftyPiercingAlleycat
The link above describes the issue I'm having when I set the textfield to become the first responder. The animation makes the placeholder to go a little diagonal instead of straight up. Any help would be appreciated. Thanks for making this awesome library.
Any chance to convert this wonderful library to Swift 2. It would be greatly appreciated :)
It runs fine on the simulator and compiles fine on both the simulator and the device. But when I run the app on the device I get the following error:
dyld: Library not loaded: @rpath/TextFieldEffects.framework/TextFieldEffects
Referenced from: /private/var/mobile/Containers/Bundle/Application/DD8E223B-5A3C-47AE-BA55-7F030765D4E5/TextFieldsDemo.app/TextFieldsDemo
Reason: image not found
(lldb)
I really like TextFieldEffects and I thought that would be awesome to be able to use it with phone number formatter as the user types in. I found PhoneNumberKit, which seemed interesting for playing with phone numbers.
However, when I tried implementing it, I realised that I need to declare it as let textField = PhoneNumberTextField()
but I declare my UITextField with var textField = HoshiTextField()
.
I went into TextFieldEffects.swift and found UITextField there, but changing it there doesn't seem like an option. (I think I should use a delegate to observe every change on the HoshiTextField, but I got very confused)
Can you please guide me on that? Also, please let me know if there are better ways than this for doing it.
Hi @raulriera, nice work on these effects, they look and function great!!
Noticed one issue when using YokoTextField. If you set the text on the field after it is already visible, the field does not animate and still shows as if the text is empty.
To reproduce, simply pre-populate a text field in viewDidAppear(animated) instead of viewWillAppear(animated) and the text field won't show the "populated" appearance until you click on it. Let me know if you need an example project to show it, happy to help!
Thanks a lot.
It would be very useful, and it would look better in my app if the rectangle would have a corner radius.
hello, Raul.
The issue same with #13 still visible in my app.
I using your library in Objective-C project, when I set text are emty string, the placeholder string do not move down.
Objective-C
_nameText = [[HoshiTextField alloc] initWithFrame:CGRectMake(xPos, yPos, WIDTH - 10, WIDTH0.1667)];
[_nameText setBorderActiveColor:[UIColor LVL_colorWithHexString:@"ffc16a" andAlpha:1.0]];
[_nameText setBorderInactiveColor:[UIColor LVL_colorWithHexString:@"d0d0d0" andAlpha:1.0]];
[_nameText setPlaceholder:@" Name:"];
[self.pageScroll addSubview:_nameText];
yPos += WIDTH0.1667 + 5;
_title = [[HoshiTextField alloc] initWithFrame:CGRectMake(xPos, yPos, WIDTH - 10, WIDTH*0.1667)];
[_title setBorderActiveColor:[UIColor LVL_colorWithHexString:@"ffc16a" andAlpha:1.0]];
[_title setBorderInactiveColor:[UIColor LVL_colorWithHexString:@"d0d0d0" andAlpha:1.0]];
[_title setPlaceholder:@" Title:"];
[self.pageScroll addSubview:_title];
yPos += WIDTH*0.1667 + 5;
_comment = [[HoshiTextField alloc] initWithFrame:CGRectMake(xPos, yPos, WIDTH - 10, WIDTH*0.1667)];
[_comment setBorderActiveColor:[UIColor LVL_colorWithHexString:@"ffc16a" andAlpha:1.0]];
[_comment setBorderInactiveColor:[UIColor LVL_colorWithHexString:@"d0d0d0" andAlpha:1.0]];
[_comment setPlaceholder:@" Comment"];
[self.pageScroll addSubview:_comment];
yPos += WIDTH*0.1667 + 5;
and when I call clear function like:
[_nameText setText:@""];
[_title setText:@""];
[_comment setText:@""];
[_nameText becomeFirstResponder];
the placeholder do not move down.
Thank & Regard,
-- Luc.
Hi,
Would there be a way to change the font of the placeholder?
Thank you for the work on the framework!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.