Created
June 10, 2014 16:51
-
-
Save dvdsgl/e596941de042348b53b7 to your computer and use it in GitHub Desktop.
Cirrious.FluentLayout makes iOS Auto Layout... fun! Especially in F#.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open MonoTouch.UIKit | |
open Cirrious.FluentLayouts.Touch | |
type PhotoViewController() = | |
inherit UIViewController() | |
let imageViewSize = 200.0f | |
let imageView = | |
let view = UIImageView( | |
BackgroundColor = UIColor.Gray, | |
ContentMode = UIViewContentMode.ScaleAspectFit, | |
TranslatesAutoresizingMaskIntoConstraints = false) | |
view | |
let photoButton = | |
let button = UIButton( | |
UIButtonType.System, | |
TranslatesAutoresizingMaskIntoConstraints = false) | |
button.SetTitle("Add photo", UIControlState.Normal) | |
button | |
let content = | |
let view = UIView(BackgroundColor = UIColor.White) | |
view.AddSubviews(imageView, photoButton) | |
view.AddConstraints [| | |
imageView.Width().EqualTo(imageViewSize) | |
imageView.Height().EqualTo(imageViewSize) | |
imageView.WithSameCenterX(view) | |
imageView.AtTopOf(view, 50.0f) | |
photoButton.WithSameCenterX(view) | |
photoButton.Below(imageView, 20.0f) | |
|] | |
view | |
override this.LoadView() = this.View <- content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment