ios


Swift UITextField Class not showing edits


Here I am trying to make a modified textfield input with Swift and Xcode. As instructed i created a class that extends the UITextField and set the properties that I want to change, however when I build the app I only see the normal text input. I feel like I'm missing something when creating classes or not returning something properly, here is my code:
First viewController:
#IBOutlet weak var verificationInput: borderBottomTextField!
borderBottomTextField Class:
class borderBottomTextField: UITextField {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.addTarget(self, action: #selector(borderBottomTextField.myFunc), for: UIControlEvents.editingDidBegin);
}
func myFunc() {
//Border
self.layer.cornerRadius = 15.0;
self.layer.borderWidth = 1.5
self.layer.borderColor = UIColor.blue.cgColor
//Background
self.backgroundColor = UIColor(white: 1, alpha: 0.0)
//Text
self.textColor = UIColor.red
self.textAlignment = NSTextAlignment.center
}
}
func myFunc() will call when borderBottomTextField detect editingDidBegin event
required init?(coder aDecoder: NSCoder) will call when you add your view via xib, when you adding subview via code you should implement initWithFrame method.
Could you show how you add borderBottomTextField to views hierarchy?
you are missing masksToBounds in myFunc(). Add self.layer.masksToBounds = false after border color

Related Links

Writing a flood-fill method in Swift
Facebook Graph API query for latest album from page
Options for sending data to server/retrying requests in background
xcode, ios, Help Image Freezes, Not Moving
Hidden property cannot be changed within an animation block
MPmoviePlayer going black after updating to IOS 9 ( swift )
Run custom script after iOS app is signed in XCode
Video frames fill only 1/4 of the view - GL
How can I change the image in the detail view to access the master view
Can I use swift 1.2 with iOS 9? [closed]
Why same nsmutablearray gives me valid value and a null on different functions used
Capture location in all states app
Does prefix works correctly in Xcode 7 beta 6?
Ios Push notification : Null would like to send you notifications
Programming Transition Loses Navigation Bar
Go back to previous controller from class swift

Categories

HOME
mocking
ssl
oozie
svg
auth0
graylog2
order
feed
redhat
api.ai
addeventlistener
telerik
http2
classloader
cross-domain
pymc3
google-weather-api
higher-order-functions
jscrollpane
google-cloud-sdk
export-to-excel
watchservice
lazy-loading
helpers
amplitude
org-mode
git-bash
google-finance
ssms-2014
core-location
phonegap-desktop-app
webfocus
parallax.js
bluebird
gecko
evercookie
google-shared-contacts
pdfstamper
increment
signing
amazon-vpc
mindstorms
uitabbarcontroller
plasticscm
http-status-code-500
html-form
netbeans-7
tastypie
getelementbyid
zenity
mit-scheme
business-logic
xnamespace
selenium2library
winobjc
lidar
java-gstreamer
radix-sort
kinto
jedi
dbfit
linq2db
spinach
dhc
access-log
openxls
java-client
gdk
httpservice
css3pie
srp
zephir
sugar.js
firebird2.1
ccombobox
visual-assist
mosek
square-cube
java-ee-5
symfony-2.2
jmdns
timespan
headless-browser
documentviewer
code-structure
msxsl
working-directory
arr
j#
bapi
datatemplate
adbwireless
spquery
remote-control
net-ssh
gedcom
gendarme
fogbugz-on-demand
docking

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App