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

current location in mapkit
Using GeoFire queries in Swift does not give useful output
ios fdk-aac pcm to aac sample
How to store critically sensitive information such as secret, key, token, encryptionKey in iOS application
Sirikit disambiguation keeps repeating
How to make the interface for a camera app on the IPhone different than the IPad for the same app?
Swift Error when trying to open other apps from my app | The operation couldn’t be completed. (OSStatus error -10814.)
Not able to set proper UITableView scroll when keyboard is shown and when keyboard resigns
Firebase Fetch data from database
IOS Tab Bar Item Popup Submenu
Getting undefined when I call the props of ReactNative GooglePlacesAutocomplete api on another component
How to convert Any to Dictionary in Swift3
Proper background message handling from Apple Watch?
Layout change for landscape/portrait
Making a strobe light app
Delete button disappeared on scrolling in edit mode of UITableview

Categories

HOME
vb.net
logstash
apt-get
android-activity
appium-ios
applet
styling
logback
entity
py.test
add-in
tcplistener
copy-paste
boxfuse
session-cookies
jscrollpane
phpbb3
nsmutableattributedstring
man
mlr
sax
rrd
memorystream
sql-server-2014-express
instance
directx-12
apache-commons-httpclient
gosublime
extraction
ecmascript-4
sinon
ibm-wcm
nomenclature
brainfuck
subscription
mamp-pro
jquery-ui-dialog
integer-programming
gretl
ctl
kombu
hapi.js
sizeof
webdeploy-3.5
screen-capture
tag-helpers
materialdrawer
jedi
google-swiffy
antiforgerytoken
diagonal
iife
prettyfaces
jet.com-apis
keyboard-navigation
ituneslibrary
sonata-media-bundle
acts-as-taggable-on
parsekit
django-endless-pagination
deap
ioerror
str-to-date
external-dependencies
micro-orm
polarssl
angularjs-module
square-cube
cassette
browserid
oncreate
qbwc
android-actionbar-compat
mysql-backup
onmouseout
adaboost
noindex
objcopy
boost-gil
.net-1.1
cluetip
sqlitemanager
usenet

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