View LayoutExample9.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.lightGrayColor()
var hLayout = HorizontalFitLayout(height: 150)
hLayout.backgroundColor = UIColor.cyanColor()
view.addSubview(hLayout)
View LayoutExample8.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.lightGrayColor()
var vLayout = VerticalFitLayout(width: view.frame.width)
vLayout.backgroundColor = UIColor.cyanColor()
view.addSubview(vLayout)
View LayoutExample7.swift
class VerticalFitLayout: VerticalLayout {
override init(width: CGFloat) {
super.init(width: width)
}
required init(coder aDecoder: NSCoder) {
View LayoutExample6.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.lightGrayColor()
var hLayout = HorizontalLayout(height: 200)
hLayout.backgroundColor = UIColor.cyanColor()
view.addSubview(hLayout)
View LayoutExample5.swift
class HorizontalLayout: UIView {
var xOffsets: [CGFloat] = []
init(height: CGFloat) {
super.init(frame: CGRectMake(0, 0, 0, height))
}
required init(coder aDecoder: NSCoder) {
View LayoutExample4.swift
class VerticalScreenLayout: VerticalLayout {
init() {
super.init(width: UIScreen.mainScreen().bounds.width)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
View LayoutExample3.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.lightGrayColor()
var vLayout = VerticalLayout(width: view.frame.width)
vLayout.backgroundColor = UIColor.cyanColor()
view.addSubview(vLayout)
View LayoutExample2.swift
class VerticalLayout: UIView {
var yOffsets: [CGFloat] = []
init(width: CGFloat) {
super.init(frame: CGRectMake(0, 0, width, 0))
}
required init(coder aDecoder: NSCoder) {
View LayoutExample1.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
println(view.frame)
view.backgroundColor = UIColor.lightGrayColor()
let view1 = UIView(frame: CGRectMake(100, 50, 100, 100))
View JSONParseDictionary.swift
// Author - Santosh Rajan
import Foundation
let string = "{\"name\": \"John\", \"age\": 35, \"children\": [\"Jack\", \"Jill\"]}"
func JSONParseDictionary(jsonString: String) -> [String: AnyObject] {
if let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding) {
if let dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: nil) as? [String: AnyObject] {
return dictionary