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

Swift convertPointFromView returns NaN when move back from child view
obejective c - Portential leak of an object stored into
When submitting a swift based cocoapod, I get this error when checking if the device is a simulator: code after 'return' will never be executed
“No such module 'Alamofire'” Xcode won't recognize Alamofire framework
Using dismissViewController on queue of multiple UIViewControllers with delegate
Running Parse Server with MongoDB on Digital Ocean
Fatal Error when connectting Objective-C framework to Swift iOS project (SpeechSDK framework)
How can I run a single script for just one matrix in a multi-matrix travis build
Why [SKAction runBlock:^(void){}] never works?
Hiding a label when phone is in landscape mode
UIProgressView - Progress Bar - SpriteKit / Swift
Xcode 7 - Localising the storyboard doesn't work properly
How to decide if an URL should be encoded or not?
Core Data lightweight migration - do existing entities have new attributes added to them?
Change coordinate of map (MapKit)
add observe to json file if there's new data

Categories

HOME
typescript
odoo-10
embedded-linux
gwt
vr
chronicle
localforage
visual-studio-2012
wso2is
wikipedia-api
jbpm
webdriver-io
player-swift
wav
superfish
aac
scrollbar
partitioning
plc
flow
teraterm
multiprocessing
similarity
google-distancematrix-api
robotium
symbolic-math
burp
intersystems
point-cloud-library
memorystream
meanjs
asp.net-identity-2
monads
opensuse
pymysql
stomp
spring-websocket
gosublime
aem-6
powerbuilder-conversion
qweb
sinon
amazon-vpc
pac
automata-theory
edeliver
gradle-tooling-api
karnaugh-map
botkit
sdcc
rtems
pulseaudio
strip-tags
requirements-management
clientscript
spring-form
website-hosting
jeditorpane
zenity
cakephp-2.3
nsd
mit-scheme
android-location
vlc-android
angularjs-filter
webmail
main-activity
xlform
metalkit
ssha
dbfit
interpreted-language
sample-data
gevent-socketio
sql-server-ce-3.5
fortrabbit
modern-ui
servlet-listeners
culture
httpservice
monk
syndication-feed
zeroclipboard
angularjs-google-maps
srp
lightstreamer
ducttape
vlfeat
gora
mms-gateway
scrollpane
google-chrome-frame
hogan.js
memento
wescheme
ariatemplates
ria
sticky-footer
force.com
ruby-1.9.2
f2c
retain
formsauthentication
pong
etrade-api
paredit
symstore
nsindexset
indextank
program-transformation
remote-control
n900
queryanalyzer
anemic-domain-model
sharepoint-feature

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