Skip to content

Cosmos configuration

Evgenii Neumerzhitckii edited this page Dec 6, 2017 · 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 (not available with Carthage setup). Alternatively, all the configuration options are accessible through the settings property of the view object.

// Set the color of a filled star
cosmosView.settings.filledColor = UIColor.orange

Star settings

Star settings describe appearance of individual stars in the Cosmos.

  • emptyBorderColor: Border color of an empty star. Default: #FF9500 color.
  • emptyBorderWidth: Width of the border for empty star. Default: 1 pixel.
  • emptyColor: Background color of an empty star. Default: transparent.
  • filledBorderColor: Border color of a filled star. Default: #FF9500 color.
  • filledBorderWidth: Width of the border for a filled star. Default: 1 pixel.
  • filledColor: 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 (.full, .half, .precise). It can either show full stars, half stars or stars partially filled according to the rating value. Default: .full. When using in interface builder use these numbers: full = 0, half = 1, precise = 2
  • 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: #7F7F7F color.
  • textFont: Font for the text. Default: dynamic type with UIFontTextStyleFootnote style.
  • textMargin: Distance between the text and the stars. Default: 5.

Custom images settings

Supply images for the filled and empty stars. By default the star is drawn from the array of points unless an image is supplied.

  • filledImage: Image used for the filled portion of the star. Default: nil.
  • emptyImage: Image used for the empty portion of the star. Default: nil.

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