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

How to solve the error “:37: parser error : EntityRef: expecting ';'” in Xcode, Objective-C
iOS new view not appearing and/or old view not disappering
How to place textfield position using tap gesture
UICollectionView must be initialized with a non-nil layout parameter. error in swift with UICollectionView
How to rotate custom marker image on google map objective c
Determine “nil” value in JSON
How to Speed up the audio Playing in MpMoviePlayerController
share extension in ios 8 with objective c
Implementing pixel-perfect background images in different orientations
iAP buy button with price tier text
Segmentation fault OR Stacktrace when using UIView with message forwarding feature of Objective-C
How to get the String Value in JSON
Add TapGestureRecogniser to UITextView
Navigation title not working properly
Chaning height of UIView
Getting same records from UITableView on Detail Button click in iOS

Categories

HOME
codeigniter
printing
opencl
gwt
sharepoint-2013
xaml
x-editable
localforage
genetic-algorithm
mocha
c++14
spacemacs
android-bluetooth
sony-camera-api
entity
microsoft-dynamics
wso2ei
yii2-advanced-app
jquery-jtable
facebook-opengraph
partitioning
raspberry-pi2
jgit
next
spring-boot-admin
pywin32
urlrewriter.net
sax
vnc
android-arrayadapter
clappr
bluebird
skyscanner
seh
inria-spoon
hamcrest
edit-distance
titanium-alloy
powerbuilder-conversion
sourcetree
jupyter-irkernel
jsonstore
pac
nexus-5
android-studio-2.1
maven-jetty-plugin
gretl
ctl
htc
masm32
manifoldcf
kie-workbench
angular2-rc5
cakephp-2.3
nsd
proc
setwindowshookex
file-import
uploadify
dual-table
clientid
laravel-forge
dbfit
ubiquity
voting
user-registration
multiscreen
iphone-5
ehcache-bigmemory
emberfire
scribe
simpleadapter
slick2d
imaging
httpservice
asf
notifydatasetchanged
django-supervisor
bonecp
twill
sonata-media-bundle
qt4.7
libtorrent-rasterbar
sysadmin
apache-commons-dbcp
mms-gateway
git-gui
sizzle
hogan.js
asp.net-session
msxsl
directoryentry
hunchentoot
unitils
executescalar
xml-database
newsgroup
large-teams
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