iOS development using Swift for C#ers
Tuesday, August 19, 2014
Button
Setup:
Drag the button onto the storyboard
Add handler:
@IBAction
func
btnClicked(btnTarget:
UIButton
!)
{
//add code here
}
On the storyboard, Right click drag from the button to yellow Viewcontroller icon and select the function btnClicked.
Text Box
Setup:
Drag the control onto the storyboard
@IBOutlet
var
txb1 :
UITextField
!
Set Text:
txb1
.
text
=
"asdasd"
Get Text:
var
strTextFromField =
txb1
.
text
Message Box
Display:
var
alert =
UIAlertController
(title:
"Alert"
, message:
"Message"
, preferredStyle:
UIAlertControllerStyle
.
Alert
)
alert.
addAction
(
UIAlertAction
(title:
"Click"
, style:
UIAlertActionStyle
.
Default
, handler:
nil
))
self
.
presentViewController
(alert, animated:
true
, completion:
nil
)
Display with Actions:
???
Label
Setup:
Drag the control onto the storyboard
@IBOutlet
var
lbl1 :
UILabel
!
Set Text
lbl1
.
text
=
"asdasd"
Get Text
var
strTextFromLabel =
lbl1
.
text
About this blog
This blog is for jotting down important chunks of codes and lessons that I will come across while learning Swift.
Home
Subscribe to:
Posts (Atom)