Examples

Greg Brown edited this page Feb 12, 2017 · 40 revisions

Code samples highlighting key features.

Radio Buttons

Example of a table view section that allows a user to select a single row at a time, similar to a group of radio buttons.

iOS

tvOS

Code

RadioButtonViewController.swift - loads view declaration from markup

RadioButtonViewController.xml - view declaration

Checkboxes

Example of a table view section that allows a user to select one or more rows at a time, similar to a group of checkboxes.

iOS

tvOS

Code

CheckboxViewController.swift - loads view declaration from markup

CheckboxViewController.xml - view declaration

Grid View

Example of using MarkupKit's LMColumnView and LMRowView to create a grid layout.

iOS

tvOS

Code

GridViewController.swift - loads view declaration from markup

GridViewController.xml - view declaration

Anchor View

Example of using the LMAnchorView class to automatically arrange user interface elements.

iOS

tvOS

Code

AnchorViewController.swift - loads view declaration from markup

AnchorViewController.xml - view declaration

Colors and Fonts

Example of using color and font tables to abstract style properties.

iOS

tvOS

Code

ColorsAndFontsViewController.swift - loads view declaration from markup and responds to size class change events

ColorsAndFontsViewController.xml - view declaration

ColorsAndFonts.json - default template properties

ColorsAndFonts~vertical.json - vertical template properties

Colors.plist - color table

Fonts.plist - font table

Includes

Example of using includes to modularize a document.

iOS

tvOS

iOS

IncludesViewController.swift - loads view declaration from markup

IncludesViewController.xml - root view declaration (includes column view)

ColumnView.xml - column view declaration (includes row views)

FirstRowView.xml - first row view declaration

SecondRowView.xml - second row view declaration

ThirdRowView.xml - third row view declaration

Sliders

Example that uses sliders to generate an RGB color value.

iOS

Code

SlidersViewController.swift - loads view declaration from markup and handles slider events

SlidersViewController.xml - view declaration

Selection View

Example of a drop-down selection view.

iOS

Code

SelectionViewController.swift - presents color picker view controller and responds to user selection

ColorPickerViewController.swift - color picker view controller

ColorPickerViewController.xml - color picker view declaration

Scroll View

Example that demonstrates the fitToWidth property of LMScrollView and the use of LMLayerView to create a floating button.

iOS

Code

ScrollViewController.swift - loads view declaration from markup and populates scroll view content

ScrollViewController.xml - view declaration

Page View

Example demonstrating the use of the LMPageView class.

iOS

  

Code

PageViewController.swift - loads view declaration from markup

PageViewController.xml - view declaration

Custom Cell View

Example of a custom table view cell implemented in markup. Cell values are updated via data binding.

iOS

tvOS

Code

CustomCellViewController.swift - loads simulated pharmacy data from JSON and produces custom cell views

PharmacyCell.swift - custom cell view implementation

PharmacyCell.xml - custom cell view declaration

pharmacies.json - simulated pharmacy data

Custom Section View

Example of implementing a custom table view section using LMTableView.

iOS

tvOS

Code

CustomSectionViewController.swift - loads static view content from markup and produces dynamic section content

CustomSectionViewController.xml - static view declaration

Custom Component View

Example of implementing a custom picker view component using LMPickerView.

iOS

Code

CustomComponentViewController.swift - loads static view content from markup and produces dynamic component content

CustomComponentViewController.xml - static view declaration

Effect View

Example of using UIVisualEffectView in markup.

iOS

tvOS

Code

EffectViewController.swift - loads view declaration from markup

EffectViewController.xml - view declaration

Gradient Views

Example of using linear and radial gradient views in markup.

iOS

 

tvOS

Code

LinearGradientViewController.swift - loads view declaration from markup

LinearGradientViewController.xml - view declaration

RadialGradientViewController.swift - loads view declaration from markup

RadialGradientViewController.xml - view declaration

Size Classes

Example demonstrating the use of size class-specific view declarations.

iOS

tvOS

Code

SizeClassViewController.swift - loads view declaration from markup and responds to size class change events

SizeClassViewController.xml - default view declaration

SizeClassViewController~horizontal.xml - horizontal view declaration

SizeClassViewController~vertical.xml - vertical view declaration

Form View

Example of using LMColumnView and LMRowView to create a simple form. Data binding is used to manage the form values.

iOS

Code

FormViewController.swift - loads view declaration from markup

FormViewController.xml - view declaration

Stack View

Examples from Apple's Auto Layout Cookbook implemented in markup.

iOS

 

Code

SimpleStackViewController.swift - loads view declaration from markup

SimpleStackViewController.xml - view declaration

NestedStackViewController.swift - loads view declaration from markup; creates aspect ratio and equal-width constraints; provides navigation to next view

NestedStackViewController.xml - view declaration

Periodic Table

Periodic table of the elements implementing using MarkupKit layout views.

iOS

tvOS

Code

PeriodicTableViewController.swift - loads view declaration from markup

PeriodicTableViewController.xml - view declaration

Collection View

Example of a custom collection view cell implemented in markup. Cell values are updated via data binding.

iOS

tvOS

Code

CollectionViewController.swift - collection view controller

CollectionViewController.xml - view declaration

ColorCell.swift - custom cell view implementation

ColorCell.xml - custom cell view declaration

Web View

Example of using WKWebView in markup.

iOS

Code

WebViewController.swift - loads view declaration from markup; handles keyboard show/hide events and button presses

WebViewController.xml - view declaration

Map View

Example of using MKMapView in markup.

iOS

Code

MapViewController.swift - loads view declaration from markup; handles keyboard show/hide events and button presses

MapViewController.xml - view declaration

Player View

Example of using LMPlayerView to display a video. The player view is embedded in a table view cell.

iOS

tvOS

Code

PlayerViewController.swift - loads view declaration from markup and manages play/pause functionality

PlayerViewController.xml - view declaration