Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class XLFormWeekDaysCell : XLFormBaseCell {
}

func updateButtons() {
let value = rowDescriptor.value as! Dictionary<String, Bool>
sundayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Sunday.description()]!
mondayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Monday.description()]!
tuesdayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Tuesday.description()]!
Expand Down
2 changes: 2 additions & 0 deletions Examples/Swift/SwiftExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="p4n-1v-pzo">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="p4n-1v-pzo">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 Xmartlabs ( http://xmartlabs.com )
//
// Swift Example Contributed by Eric Gu
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,71 +25,167 @@

class UICustomizationFormViewController : XLFormViewController {

//MARK: Tags

private enum Tags : String {
case Name = "Name"
case Button = "Button"
case FullName = "FULLNAME"
case DateOfBirth = "DATEOFBIRTH"
case Email = "EMAIL"
case Button = "JOINTEAM"
}

//MARK: Customization Constants

private let kPrimaryColor = UIColor.whiteColor()
private let kSecondaryColor = UIColor(red: 0/255, green: 181/255, blue: 229/255, alpha: 1.0)
private let kStandardFontSize:CGFloat = 17
private let kStandardFontName = "AppleSDGothicNeo-Regular"
private let kBackgroundColor = UIColor.blackColor()
private let kHeaderHeight: CGFloat = 40

//MARK: Init

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
initializeForm()
}

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
initializeForm()
}

//MARK: View Setup

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(false)
view.backgroundColor = kBackgroundColor
tableView.separatorInset.right = tableView.separatorInset.left
tableView.backgroundColor = kBackgroundColor
tableView.rowHeight = super.tableView.rowHeight
tableView.tableFooterView = UIView(frame: CGRectZero)
navigationController?.navigationBar.backgroundColor = kBackgroundColor
navigationController?.navigationBar.barTintColor = kBackgroundColor
navigationController?.navigationBar.translucent = false
navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: kStandardFontName, size: 20)!, NSForegroundColorAttributeName: kPrimaryColor]
navigationController?.navigationBar.tintColor = kPrimaryColor
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: kStandardFontName, size: 15)!], forState: UIControlState.Normal)
navigationController?.navigationBar.barStyle = UIBarStyle.Black
}

override func viewWillDisappear(animated: Bool) {
//Optional Function - Resets Shared Nav Customization Before Returning to Examples Main Table View
super.viewWillDisappear(false)
navigationController?.navigationBar.backgroundColor = UIColor.grayColor()
navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
navigationController?.navigationBar.translucent = true
navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont.boldSystemFontOfSize(18), NSForegroundColorAttributeName: UIColor.blackColor()]
navigationController?.navigationBar.tintColor = view.tintColor
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.systemFontOfSize(17)], forState: UIControlState.Normal)
navigationController?.navigationBar.barStyle = UIBarStyle.Default
}

//MARK: Form

func initializeForm() {

let form : XLFormDescriptor
let customForm : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor

form = XLFormDescriptor(title: "UI Customization")
customForm = XLFormDescriptor(title: "UI Customization")

section = XLFormSectionDescriptor.formSectionWithTitle("Basics") as XLFormSectionDescriptor
customForm.addFormSection(section)

//FULLNAME
row = XLFormRowDescriptor(tag: Tags.FullName.rawValue, rowType: XLFormRowDescriptorTypeText, title: "Full Name")

section = XLFormSectionDescriptor()
form.addFormSection(section)

// Name
row = XLFormRowDescriptor(tag: Tags.Name.rawValue, rowType: XLFormRowDescriptorTypeText, title:"Name")
// change the background color
row.cellConfigAtConfigure["backgroundColor"] = UIColor.greenColor()
// font
row.cellConfig["textLabel.font"] = UIFont.systemFontOfSize(30)
// background color
row.cellConfig["textField.backgroundColor"] = UIColor.grayColor()
// font
row.cellConfig["textField.font"] = UIFont.systemFontOfSize(25)
// alignment
row.cellConfig["textField.textAlignment"] = NSTextAlignment.Right.rawValue
row.cellConfig["backgroundColor"] = kBackgroundColor
row.cellConfig["textLabel.textColor"] = kPrimaryColor
row.cellConfig["self.tintColor"] = kPrimaryColor
row.cellConfig["textLabel.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!

row.cellConfig["textField.textColor"] = kPrimaryColor
row.cellConfig["textField.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!
row.cellConfigAtConfigure["textField.placeholder"] = "Required..."
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
row.value = "John Doe"
section.addFormRow(row)

// Date Of Birth
row = XLFormRowDescriptor(tag: Tags.DateOfBirth.rawValue, rowType: XLFormRowDescriptorTypeDateInline, title:"Date Of Birth")
row.value = NSDate()
row.cellConfig["maximumDate"] = NSDate()
row.cellConfig["backgroundColor"] = kBackgroundColor
row.cellConfig["textLabel.textColor"] = kPrimaryColor
row.cellConfig["self.tintColor"] = kPrimaryColor

row.cellConfig["textLabel.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!
row.cellConfig["detailTextLabel.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!
row.cellConfig["detailTextLabel.textColor"] = kPrimaryColor

section.addFormRow(row)

// Email
row = XLFormRowDescriptor(tag: Tags.Email.rawValue, rowType: XLFormRowDescriptorTypeEmail, title: "Email")
row.value = "[email protected]"
//row.addValidator(XLFormValidator.emailValidator())
//row.required = true

row.cellConfig["backgroundColor"] = kBackgroundColor
row.cellConfig["textLabel.textColor"] = kPrimaryColor
row.cellConfig["textLabel.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!
row.cellConfig["self.tintColor"] = kPrimaryColor


row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
row.cellConfig["textField.textColor"] = kPrimaryColor
row.cellConfig["textField.font"] = UIFont(name: kStandardFontName, size: kStandardFontSize)!
section.addFormRow(row)

// Section
section = XLFormSectionDescriptor()
form.addFormSection(section)
section = XLFormSectionDescriptor.formSectionWithTitle("Join Team") as XLFormSectionDescriptor
customForm.addFormSection(section)

//Button
row = XLFormRowDescriptor(tag: Tags.Button.rawValue, rowType: XLFormRowDescriptorTypeButton, title:"Button")
row = XLFormRowDescriptor(tag: Tags.Button.rawValue, rowType: XLFormRowDescriptorTypeButton, title:"Join Team")
row.cellConfigAtConfigure["backgroundColor"] = UIColor.purpleColor()
row.cellConfig["textLabel.color"] = UIColor.whiteColor()
row.cellConfig["textLabel.font"] = UIFont.systemFontOfSize(40)
row.cellConfig["textLabel.color"] = kPrimaryColor
row.cellConfig["textLabel.font"] = UIFont(name: kStandardFontName, size: 25)!
section.addFormRow(row)

self.form = form
form = customForm
}

//MARK: TableView

override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
header.contentView.backgroundColor = kSecondaryColor
header.textLabel.textColor = kPrimaryColor
header.textLabel.font = UIFont(name: kStandardFontName, size: 18)!
header.frame.size.height = tableView.rowHeight
}

override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return kHeaderHeight
}

override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.1
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// change cell height of a particular cell
if self.form.formRowAtIndex(indexPath)?.tag == "Name" {

if self.form.formRowAtIndex(indexPath)?.tag == Tags.Button.rawValue {
return 60.0
}
else if self.form.formRowAtIndex(indexPath)?.tag == "Button" {
return 100.0
else {
return super.tableView.rowHeight
}
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}


}

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ row = [XLFormRowDescriptor formRowDescriptorWithTag:@"title" rowType:XLFormRowDe
**Swift**
```Swift
row = XLFormRowDescriptor(tag: "title", rowType: XLFormRowDescriptorTypeText, title: "title")
row.cellConfig.setObject(UIColor.blackColor(), forKey: "backgroundColor")
row.cellConfig.setObject(UIColor.whiteColor(), forKey: "textLabel.textColor")
row.cellConfig["backgroundColor"] = UIColor.blackColor()
row.cellConfig["textLabel.textColor"] = UIColor.whiteColor()
section.addFormRow(row)
```

Expand Down Expand Up @@ -886,10 +886,10 @@ You can change the font or any other table view cell property using the `cellCon

**Swift**
```Swift
row.cellConfig.setObject(UIColor.whiteColor(), forKey: "self.tintColor")
row.cellConfig.setObject(UIFont(name: "AppleSDGothicNeo-Regular", size: 17)!, forKey: "textLabel.font")
row.cellConfig.setObject(UIColor.whiteColor(), forKey: "textField.textColor")
row.cellConfig.setObject(UIFont(name: "AppleSDGothicNeo-Regular", size: 17)!, forKey: "textField.font")
row.cellConfig["self.tintColor"] = UIColor.whiteColor()
row.cellConfig["textLabel.font"] = UIFont(name: "AppleSDGothicNeo-Regular", size: 17)
row.cellConfig["textField.textColor"] = UIColor.whiteColor()
row.cellConfig["textField.font"] = UIFont(name: "AppleSDGothicNeo-Regular", size: 17)
```

For further details, please take a look at [UICustomizationFormViewController.m](/Examples/Objective-C/Examples/UICustomization/UICustomizationFormViewController.m) example.
Expand All @@ -906,7 +906,7 @@ Each XLFormDateCell has a `minimumDate` and a `maximumDate` property. To set a d

**Swift**
```Swift
row.cellConfig.setObject(NSDate(), forKey: "maximumDate")
row.cellConfig["maximumDate"] = NSDate()
```

####How to disable the entire form (read only mode).
Expand Down