Skip to content

Cosmos configuration

Evgenii Neumerzhitckii edited this page Jun 22, 2015 · 40 revisions
Cosmic Fireball Falling Over ALMA

Atacama Large Millimeter Array. The photo was taken by Christoph Malin. Source: European Southern Observatory.

Use Storyboard or code

One can configure Cosmos view directly from the storyboard using the attributes inspector. Alternatively, all the configuration options are accessible through the settings property of the view object.

// Set the color of a filled star
view.settings.colorFilled = UIColor.orangeColor()

Star settings

Star settings describe appearance of individual stars in the Cosmos.

  • borderColorEmpty: Border color of an empty star. Default: #FF9500 color.
  • borderWidthEmpty: Width of the border for the empty star. Default: 1.
  • colorEmpty: Background color of an empty star. Default: transparent.
  • colorFilled: Background color of a filled star. Default: #FF9500 color.
  • fillMode: Defines how the star is filled when the rating value is not a whole integer. It can either show full stars, half stars or stars partially filled according to the rating value. Default: .Full.
  • starMargin: Distance between stars. Default: 5.
  • starPoints: Array of points for drawing the star with size of 100 by 100 pixels. Supply your points if you need to draw a different shape.
  • starSize: Size of a single star. Default: 20.
  • totalStars: The maximum number of stars to be shown. Default: 5.

Text settings

Use the text settings to style the optional text that is shown on the right edge of the Cosmos.

  • textColor: Color of the text. Default: #FF9500 color.
  • textFont: Font for the text. Default: dynamic type with UIFontTextStyleFootnote style.
  • textMargin: Distance between the text and the stars. Default: 5.

Touch settings

Touch settings describe the behaviour of Cosmos when used as in input.

  • minTouchRating: The lowest rating that user can set by touching the stars. Default: 1.

  • updateOnTouch: When true the star fill level is updated when user touches the Cosmos view. When false the Cosmos view only shows the rating and does not act as the input control. Default: true.

Clone this wiki locally