Skip to content

Stylesheet Property Reference

MyFiziq edited this page Jun 11, 2018 · 34 revisions

Table of Contents

  1. Property Value Types and Formats
    1. Boolean

As of version 0.9.10, the keyword current can be used as a value for any property to instruct InterfaCSS to forgo setting that property. This can for instance be useful to prevent overwriting of a property value when the value has been modified in code, or in case the default value of the property is desired.

  • YES or NO - see -[NSString boolValue] for more supported values
  • Simple boolean expressions (parsed using NSPredicate)
  • A number - integer or floating point.
  • A simple mathematical expression, like 1 + @myVariable * 2 (parsed using NSExpression)

Property dependent, but always a expressed as a string on the form enumValue (i.e. no quotes). The enum value can either be the full enum name (e.g. UIActivityIndicatorViewStyleWhiteLarge) or a shorthand form, which can be derived by removing the enum type prefix from the enum name (e.g. whiteLarge).

See ISSLayout Reference.

  • insets(top, left, bottom, right)
  • image.png or image(image.png)
  • image(image.png, leftCapWidth, topCapHeight)
    • Uses [UIImage stretchableImageWithLeftCapWidth:topCapHeight]
  • image(image.png, top, left, bottom, right)
    • Uses [UIImage resizableImageWithCapInsets:]
  • Quotes around filename are optional
  • offset(horizontal, vertical)
  • font-name size, for example: HelveticaNeue-Medium 14

Also, the following functions can be applied to fonts, to produce a new font value

  • bigger(font, sizeIncrement)
  • smaller(font, sizeDecrement)
  • fontWithSize(font, size)
  • rgb(r, g, b) - example: rgb(255, 128, 0)
  • rgba(r, g, b, a) - example: rgba(255, 128, 0, 0.5)
  • Hex string, i.e. #ffffff
  • UIColor predefined colors, i.e. red, darkGray
  • Create pattern image color by specifying an image value

Furthermore, the following functions can be applied to colors, to produce new colors:

  • darken(color, percent)
  • lighten(color, percent)
  • saturate(color, percent)
  • desaturate(color, percent)
  • fadein(color, percent)
  • fadeout(color, percent)
  • gradient(fromColor, toColor)

Color functions (except gradient) can also be nested, for instance: fadeout(darken(yellow, 20%), 50%)

Same as UIColor.

Fixed values

rect(x, y, width, height) - creates a CGRect with absolute point values

Simple parent/window insets

  • parent - creates a CGRect with the bounds of the parent view
  • parent(xInset, yInset) - creates a CGRect using the bounds of the parent view and with the specified insets applied (using CGRectInset)
  • window - creates a CGRect with the bounds of the main window
  • window(xInset, yInset) - creates a CGRect using the bounds of the main window and with the specified insets applied (using CGRectInset)

Parent-relative sizing and insets

size(width, height) - creates a CGRect with width/height in absolute point values or parent relative values. Relative values can either be percentage values like 50% or the keyword auto. The auto keyword is only useful if insets are specified along with the size, for instance: size(auto, 50%).left(5%).right(50). When auto is used, InterfaCSS makes sure that the sum of width/height and insets always adds up to the width/height of the parent. The auto keyword can also be used for insets, for instance to achieve horizontal or vertical centering, e.g: size(100, 100).left(auto).right(auto).

Insets are specified like this:

  • One at a time: size(width, height).top(inset).left(inset).bottom(inset).right(inset) or
  • All at once: size(width, height).insets(topInset, leftInset, bottomInset, rightInset)

Size-to-fit

sizeToFit(width, height) - creates a CGRect by calling -[UIView sizeThatFits:], using width & height (in absolute point values or parent relative (percentage) values) as parameter. Insets can be used in the same way as specified above.

  • point(width, height) - creates a CGPoint with absolute point values
  • parent - creates a CGPoint centered in the parent view
  • parent(xOffset, yOffset) - creates a CGPoint centered in the parent view, with the specified offset
  • window - creates a CGPoint centered in the main window
  • window(xOffset, yOffset) - creates a CGPoint centered in the main window, with the specified offset
  • size(width, height)
  • rotate(degrees)
  • translate(xOffset, yOffset)
  • scale(xScale, yScale)
  • Combine one or more of the three transforms by separating them with whitespace.
  • "A String"
  • 'A String'
  • AString
  • You can also make strings localized (NSLocalizedString) like this: L("string") or localized("string")

Attributed strings are specified on the form

"substring1" (attribute: value, ...), "substring2" (attribute: value, ...), ...

The following attributes may be specified for attributed strings:

Example: attributedText: "hello" (font: HelveticaNeue-Medium 12, color: orange, baselineOffset: 1) " world" (font: HelveticaNeue-Bold 14, color: red);

Some properties support specifying a set of parameters (or conditions) after the property name. These parameters are always expressed as enumeration values, see each property for supported types and the order of the parameters. Parameters are expressed like this: titleColor(highlighted): red. Multiple parameter values are separated by comma (,).

Below is a reference of the supported parameter types and possible values:

  • Control state parameters:

    • normal : UIControlStateNormal
    • normalHighlighted : UIControlStateNormal | UIControlStateHighlighted
    • highlighted : UIControlStateNormal | UIControlStateHighlighted
    • selected : UIControlStateSelected
    • selectedHighlighted : UIControlStateSelected | UIControlStateHighlighted
    • disabled : UIControlStateDisabled
  • Bar metrics:

    • metricsDefault : UIBarMetricsDefault
    • metricsLandscapePhone : UIBarMetricsLandscapePhone
    • metricsLandscapePhonePrompt : UIBarMetricsLandscapePhonePrompt
    • metricsDefaultPrompt : UIBarMetricsDefaultPrompt
  • Segment control segments:

    • segmentAny : UISegmentedControlSegmentAny
    • segmentLeft : UISegmentedControlSegmentLeft
    • segmentCenter : UISegmentedControlSegmentCenter
    • segmentRight : UISegmentedControlSegmentRight
    • segmentAlone : UISegmentedControlSegmentAlone
  • Bar position:

    • barPositionAny : UIBarPositionAny
    • barPositionBottom : UIBarPositionBottom
    • barPositionTop : UIBarPositionTop
    • barPositionTopAttached : UIBarPositionTopAttached
  • Search bar:

    • iconBookmark : UISearchBarIconBookmark
    • iconClear : UISearchBarIconClear
    • iconResultsList : UISearchBarIconResultsList
    • iconSearch : UISearchBarIconSearch

The following size classes may be used in style declarations, to impose conditions on when a specific style is active or not:

Interface orientation

  • landscape
  • landscapeLeft
  • landscapeRight
  • portrait
  • portraitUpright
  • portraitUpsideDown

Device type

  • pad
  • phone
  • tv

Size classes

  • regularWidth
  • compactWidth
  • regularHeight
  • compactHeight

OS version and device model

  • minosversion
  • maxosversion
  • devicemodel

Screen dimensions

  • screenwidth
  • screenwidthlessthan
  • screenwidthgreaterthan
  • screenheight
  • screenheightlessthan
  • screenheightgreaterthan

UI element state

  • enabled
  • disabled

Structural

  • nthchild
  • nthlastchild
  • onlychild
  • firstchild
  • lastchild
  • nthoftype
  • nthlastoftype
  • onlyoftype
  • firstoftype
  • lastoftype
  • empty

Below is a listing of all supported properties, listed under the UIKit class they belong to.

Class Type Enum values Parameter values
alpha Number
autoresizesSubviews Boolean
autoresizingMask Enum left, none, bottom, right, width, height, top
backgroundColor UIColor
bounds CGRect
center CGPoint
clearsContextBeforeDrawing Boolean
clipsToBounds Boolean
contentMode Enum top, redraw, scaleToFill, bottomLeft, bottomRight, scaleAspectFit, topRight, bottom, scaleAspectFill, topLeft, right, left, center
contentScaleFactor Number
exclusiveTouch Boolean
frame CGRect
hidden Boolean
(layer.)anchorPoint CGPoint
(layer.)borderColor CGColor
(layer.)borderWidth Number
(layer.)cornerRadius Number
layout Layout
layoutMargins UIEdgeInsets
multipleTouchEnabled Boolean
opaque Boolean
tintAdjustmentMode Enum normal, dimmed, automatic
tintColor UIColor
transform CGAffineTransform
userInteractionEnabled Boolean
Class Type Enum values Parameter values
activityIndicatorViewStyle Enum white, whiteLarge, gray
color UIColor
hidesWhenStopped Boolean
Class Type Enum values Parameter values
backButtonBackgroundImage UIImage UIControlState, UIBarMetrics
backButtonBackgroundVerticalPositionAdjustment Number UIBarMetrics
backButtonTitlePositionAdjustment UIOffset UIBarMetrics
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
backgroundVerticalPositionAdjustment Number UIBarMetrics
enabled Boolean
font UIFont UIControlState
image UIImage UIControlState
imageInsets UIEdgeInsets
landscapeImagePhone UIImage
landscapeImagePhoneInsets UIEdgeInsets
shadowColor UIColor UIControlState
shadowOffset UIOffset UIControlState
style Enum plain, done, bordered
textColor UIColor UIControlState
title NSString
titlePositionAdjustment UIOffset UIBarMetrics
width Number
Class Type Enum values Parameter values
adjustsImageWhenDisabled Boolean
adjustsImageWhenHighlighted Boolean
attributedTitle NSAttributedString
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
contentEdgeInsets UIEdgeInsets
image UIImage UIControlState
imageEdgeInsets UIEdgeInsets
reversesTitleShadowWhenHighlighted Boolean
showsTouchWhenHighlighted Boolean
title NSString UIControlState
titleColor UIColor UIControlState
titleEdgeInsets UIEdgeInsets
titleShadowColor UIColor UIControlState
titleLabel * UILabel
imageView * UIImageView
Class Type Enum values Parameter values
allowsMultipleSelection Boolean
allowsSelection Boolean
nested flow layout properties TODO
Class Type Enum values Parameter values
contentHorizontalAlignment Enum left, fill, right, center
contentVerticalAlignment Enum top, bottom, fill, center
enabled Boolean
highlighted Boolean
selected Boolean
Class Type Enum values Parameter values
highlightedImage UIImage
image UIImage UIControlState
Class Type Enum values Parameter values
adjustsFontSizeToFitWidth Boolean
attributedText NSAttributedString
baselineAdjustment Enum none, alignBaselines, alignCenters
font UIFont UIControlState
highlightedTextColor UIColor
lineBreakMode Enum wordWrapping, charWrapping, clipping, truncatingHead, truncatingTail, truncatingMiddle
minimumFontSize Number
minimumScaleFactor Number
numberOfLines Number
preferredMaxLayoutWidth Number
shadowColor UIColor UIControlState
shadowOffset UIOffset UIControlState
text NSString
textAlignment Enum left, right, center
textColor UIColor UIControlState
Class Type Enum values Parameter values
backIndicatorImage UIImage
backIndicatorTransitionMaskImage UIImage
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
barStyle Enum default, blackTranslucent, black, blackOpaque
barTintColor UIColor
font UIFont UIControlState
shadowColor UIColor UIControlState
shadowImage UIImage UIBarPosition
shadowOffset UIOffset UIControlState
textColor UIColor UIControlState
translucent Boolean
Class Type Enum values Parameter values
progressImage UIImage
progressTintColor UIColor
progressViewStyle Enum bar, default
trackImage UIImage
trackTintColor UIColor
Class Type Enum values Parameter values
alwaysBounceHorizontal Boolean
alwaysBounceVertical Boolean
bounces Boolean
bouncesZoom Boolean
canCancelContentTouches Boolean
contentInset UIEdgeInsets
contentOffset CGPoint
contentSize CGSize
decelerationRate Enum fast, normal
delaysContentTouches Boolean
directionalLockEnabled Boolean
indicatorStyle Enum white, default, black
keyboardDismissMode Enum none, onDrag, interactive
maximumZoomScale Number
minimumZoomScale Number
pagingEnabled Boolean
scrollEnabled Boolean
scrollIndicatorInsets UIEdgeInsets
scrollsToTop Boolean
showsHorizontalScrollIndicator Boolean
showsVerticalScrollIndicator Boolean
Class Type Enum values Parameter values
autocapitalizationType Boolean
autocorrectionType Enum no, default, yes
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
barStyle Enum default, blackTranslucent, black, blackOpaque
barTintColor UIColor
imageForSearchBarIcon UIImage UISearchBar, UIControlState
keyboardType Enum numbersAndPunctuation, emailAddress, default, numberPad, twitter, webSearch, phonePad, alphabet, decimalPad, namePhonePad, URL, asciiCapable
placeholder NSString
positionAdjustmentForSearchBarIcon UIOffset UISearchBar
prompt NSString
scopeBarBackgroundImage UIImage
scopeBarButtonBackgroundImage UIImage UIControlState
scopeBarButtonDividerImage UIImage UIControlState
scopeBarButtonTitleFont UIFont UIControlState
scopeBarButtonTitleShadowColor UIColor UIControlState
scopeBarButtonTitleShadowOffset UIOffset UIControlState
scopeBarButtonTitleTextColor UIColor UIControlState
searchBarStyle Enum prominent, default, minimal
searchFieldBackgroundImage UIImage UIControlState
searchFieldBackgroundPositionAdjustment UIOffset
searchResultsButtonSelected Boolean
searchTextPositionAdjustment UIOffset
showsBookmarkButton Boolean
showsCancelButton Boolean
showsScopeBar Boolean
showsSearchResultsButton Boolean
spellCheckingType Enum no, default, yes
text NSString
translucent Boolean
Class Type Enum values Parameter values
apportionsSegmentWidthsByContent Boolean
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
contentPositionAdjustment UIOffset UISegmentedControl, UIBarMetrics
dividerImage UIImage UIControlState, UIControlState, UIBarMetrics
font UIFont UIControlState
shadowColor UIColor UIControlState
shadowOffset UIOffset UIControlState
textColor UIColor UIControlState
Class Type Enum values Parameter values
maximumTrackImage UIImage UIControlState
maximumTrackTintColor UIColor
maximumValueImage UIImage
minimumTrackImage UIImage UIControlState
minimumTrackTintColor UIColor
minimumValueImage UIImage
thumbImage UIImage UIControlState
thumbTintColor UIColor
Class Type Enum values Parameter values
autorepeat Boolean
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
continuous Boolean
decrementImage UIImage UIControlState
dividerImage UIImage UIControlState
incrementImage UIImage UIControlState
maximumValue Number
minimumValue Number
stepValue Number
wraps Boolean
Class Type Enum values Parameter values
offImage UIImage
onImage UIImage
onTintColor UIColor
thumbTintColor UIColor
Class Type Enum values Parameter values
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
barStyle Enum default, blackTranslucent, black, blackOpaque
barTintColor UIColor
itemPositioning Enum fill, centered, automatic
itemSpacing Number
itemWidth Number
selectedImageTintColor UIColor
selectionIndicatorImage UIImage
shadowImage UIImage UIBarMetrics
translucent Boolean
Class Type Enum values Parameter values
selectedImage UIImage
titlePositionAdjustment UIOffset UIBarMetrics, UIBarPosition
Class Type Enum values Parameter values
allowsMultipleSelection Boolean
allowsMultipleSelectionDuringEditing Boolean
allowsSelection Boolean
allowsSelectionDuringEditing Boolean
estimatedRowHeight Number
estimatedSectionFooterHeight Number
estimatedSectionHeaderHeight Number
rowHeight Number
sectionFooterHeight Number
sectionHeaderHeight Number
sectionIndexBackgroundColor UIColor
sectionIndexColor UIColor
sectionIndexMinimumDisplayRowCount Number
sectionIndexTrackingBackgroundColor UIColor
separatorColor UIColor
separatorInset UIEdgeInsets
separatorStyle Enum none, singleLine, singleLineEtched
tableHeaderView * UIView
tableFooterView * UIView
Class Type Enum values Parameter values
accessoryType Enum none, detailButton, disclosureIndicator, disclosureButton, checkmark
editing Boolean
editingAccessoryType Enum none, detailButton, disclosureIndicator, disclosureButton, checkmark
highlighted Boolean
indentationLevel Number
indentationWidth Number
selected Boolean
selectionStyle Enum gray, none, default, blue
separatorInset UIEdgeInsets
shouldIndentWhileEditing Boolean
showsReorderControl Boolean
backgroundView * UIView
contentView * UIView
detailTextLabel * UILabel
imageView * UIImageView
multipleSelectionBackgroundView * UIView
selectedBackgroundView * UIView
textLabel * UILabel
Class Type Enum values Parameter values
adjustsFontSizeToFitWidth Boolean
autocapitalizationType Boolean
autocorrectionType Enum no, default, yes
attributedText NSAttributedString
background UIImage
borderStyle Enum roundedRect, none, bezel, line
clearsOnBeginEditing Boolean
clearsOnInsertion Boolean
disabledBackground UIImage
enablesReturnKeyAutomatically Boolean
font UIFont UIControlState
keyboardAppearance Enum alert, dark, default, light
keyboardType Enum numbersAndPunctuation, emailAddress, default, numberPad, twitter, webSearch, phonePad, alpabet, decimalPad, namePhonePad, URL, asciiCapable
minimumFontSize Number
minimumScaleFactor Number
placeholder NSString
returnKeyType Enum default, next, route, search, yahoo, done, emergencyCall, send, go, google, join
secureTextEntry Boolean
spellCheckingType Enum no, default, yes
text NSString
textAlignment Enum left, right, center
textColor UIColor UIControlState
inputAccessoryView * UIView
inputView * UIView
Class Type Enum values Parameter values
allowsEditingTextAttributes Boolean
autocapitalizationType Boolean
autocorrectionType Enum no, default, yes
attributedText NSAttributedString
clearsOnInsertion Boolean
dataDetectorTypes Enum all, none, calendarEvent, link, address, phoneNumber
editable Boolean
enablesReturnKeyAutomatically Boolean
font UIFont UIControlState
keyboardAppearance Enum alert, dark, default, light
keyboardType Enum numbersAndPunctuation, emailAddress, default, numberPad, twitter, webSearch, phonePad, alpabet, decimalPad, namePhonePad, URL, asciiCapable
placeholder NSString
returnKeyType Enum default, next, route, search, yahoo, done, emergencyCall, send, go, google, join
secureTextEntry Boolean
selectable Boolean
spellCheckingType Enum no, default, yes
text NSString
textAlignment Enum left, right, center
textColor UIColor UIControlState
textContainerInset UIEdgeInsets
inputAccessoryView * UIView
inputView * UIView
Class Type Enum values Parameter values
backgroundImage UIImage UIControlState, UIBarMetrics, UIBarPosition
barStyle Enum default, blackTranslucent, black, blackOpaque
barTintColor UIColor
shadowImage UIImage UIBarPosition
translucent Boolean
Class Type Enum values Parameter values
allowsInlineMediaPlayback Boolean
dataDetectorTypes Enum all, none, calendarEvent, link, address, phoneNumber
gapBetweenPages Number
keyboardDisplayRequiresUserAction Boolean
mediaPlaybackAllowsAirPlay Boolean
mediaPlaybackRequiresUserAction Boolean
pageLength Number
paginationBreakingMode Enum page, column
paginationMode Enum bottomtotop, righttoleft, toptobottom, lefttoright, unpaginated
scalesPageToFit Boolean
suppressesIncrementalRendering Boolean

* Valid prefix for nested properties