{"id":2727,"url":"https://github.com/evgenyneu/Cosmos","last_synced_at":"2025-08-03T00:32:28.656Z","repository":{"id":23872767,"uuid":"27251534","full_name":"evgenyneu/Cosmos","owner":"evgenyneu","description":"A star rating control for iOS/tvOS written in Swift","archived":false,"fork":false,"pushed_at":"2024-09-03T22:43:08.000Z","size":4888,"stargazers_count":2205,"open_issues_count":56,"forks_count":370,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-07-30T18:49:49.526Z","etag":null,"topics":["ios","star-rating","swift","tvos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evgenyneu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-28T04:23:24.000Z","updated_at":"2025-07-24T06:00:04.000Z","dependencies_parsed_at":"2022-07-12T16:07:41.463Z","dependency_job_id":"4a5110dc-b603-4f3b-99c1-ff99129cf3c4","html_url":"https://github.com/evgenyneu/Cosmos","commit_stats":{"total_commits":564,"total_committers":26,"mean_commits":"21.692307692307693","dds":"0.46099290780141844","last_synced_commit":"4dc8ad618d48998f900888813e8eea4e7b8eb484"},"previous_names":["marketplacer/cosmos"],"tags_count":70,"template":false,"template_full_name":null,"purl":"pkg:github/evgenyneu/Cosmos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evgenyneu%2FCosmos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evgenyneu%2FCosmos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evgenyneu%2FCosmos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evgenyneu%2FCosmos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evgenyneu","download_url":"https://codeload.github.com/evgenyneu/Cosmos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evgenyneu%2FCosmos/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267929322,"owners_count":24167449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","star-rating","swift","tvos"],"created_at":"2024-01-05T20:16:21.236Z","updated_at":"2025-08-03T00:32:28.232Z","avatar_url":"https://github.com/evgenyneu.png","language":"Swift","funding_links":[],"categories":["UI","HarmonyOS"],"sub_categories":["Rating Stars","Other free courses","Windows Manager"],"readme":"# Cosmos, a star rating control for iOS and tvOS\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods Version](https://img.shields.io/cocoapods/v/Cosmos.svg?style=flat)](http://cocoadocs.org/docsets/Cosmos)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n[![License](https://img.shields.io/cocoapods/l/Cosmos.svg?style=flat)](LICENSE)\n[![Platform](https://img.shields.io/cocoapods/p/Cosmos.svg?style=flat)](http://cocoadocs.org/docsets/Cosmos)\n\n\u003cimg src='https://github.com/evgenyneu/Cosmos/raw/master/graphics/Screenshots/cosmos_star_rating_control_for_ios_swift_space.png' alt='Cosmos, star rating control for iOS / Swift' width='350'\u003e\n\nThis is a UI control for iOS and tvOS written in Swift. It shows a star rating and takes rating input from the user. Cosmos is a subclass of a UIView that will allow your users to post those inescapable 1-star reviews!\n\n* Shows star rating with an optional text label.\n* Can be used as a rating input control (iOS only).\n* Cosmos view can be customized in the Storyboard without writing code.\n* Includes different star filling modes: full, half-filled and precise.\n* Cosmos is accessible and works with voice-over.\n* Supports right-to-left languages.\n\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Drawings/1280px-Sirius_A_and_B_artwork.jpg'\n  alt=\"Binary star system of Sirius A and Sirius B (artist's impression)\" width='450'\u003e\n\n*Picture of binary star system of Sirius A and Sirius B by [NASA](http://www.nasa.gov), [ESA](http://www.esa.int/ESA) and G. Bacon ([STScI](http://www.stsci.edu/portal/)). Source: [spacetelescope.org](http://www.spacetelescope.org/images/heic0516b/).*\n\n## Video tutorial\n\nThanks to Alex Nagy from [rebeloper.com](https://rebeloper.com/) for creating this amazing [video tutorial](https://www.youtube.com/watch?v=Y4A_y29cy7Q) that shows how to use and customize Cosmos from code.\n\n\u003ca href=\"https://www.youtube.com/watch?v=Y4A_y29cy7Q\" target=\"_blank\"\u003e\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Youtube/rebel_developer/rebel_developer_cosmos_2.jpg' width='450' alt='Cosmos rating video tutorial for Swift 4.2 (Xcode10)'\u003e\u003c/a\u003e\n\n\n## Setup\n\nThere are various ways you can add Cosmos to your Xcode project.\n\n#### Add source (iOS 8+)\n\nSimply add [CosmosDistrib.swift](https://github.com/evgenyneu/Cosmos/blob/master/Distrib/CosmosDistrib.swift) file into your Xcode project.\n\n#### Setup with Carthage (iOS 8+)\n\nAlternatively, add `github \"evgenyneu/Cosmos\" ~\u003e 25.0` to your Cartfile and run `carthage update`.\n\n#### Setup with CocoaPods (iOS 8+)\n\nIf you are using CocoaPods add this text to your Podfile and run `pod install`.\n\n    use_frameworks!\n    target 'Your target name'\n    pod 'Cosmos', '~\u003e 25.0'\n\n\n#### Setup with Swift Package Manager\n\n* In Xcode 11+ select *File \u003e Packages \u003e Add Package Dependency...*.\n* Enter this project's URL: https://github.com/evgenyneu/Cosmos.git\n\n\n#### Legacy Swift versions\n\nSetup a [previous version](https://github.com/evgenyneu/Cosmos/wiki/Legacy-Swift-versions) of the library if you use an older version of Swift.\n\n\n## Usage\n\n\n1) Drag `View` object from the *Object Library* into your storyboard.\n\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Screenshots/cosmos_ios_view_control_attributes_inspector.png' width='256' alt='Add view control in attributes inspector'\u003e\n\n\n2) Set the view's class to `CosmosView` in the *Identity Inspector*. Set its *module* property to `Cosmos`, unless you used the file setup method.\n\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Screenshots/cosmos_storyboard_class_3.png' width='259' alt='Add Cosmos rating view to the storyboard'\u003e\n\n*tvOS note*: read the collowing [setup instructions for tvOS](https://github.com/evgenyneu/Cosmos/wiki/tvOS-CocoaPods-error) if you see build errors at this stage.\n\n\n3) Customize the Cosmos view appearance in the *Attributes Inspector*. If storyboard does not show the stars click **Refresh All Views** from the **Editor** menu.\n\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Screenshots/cosmos_customize_in_storyboard_2.png' width='502' alt='Customize cosmos appearance in the attributes inspector in Xcode.'\u003e\n\n\n## Positioning the Cosmos view\n\nOne can position the Cosmos view using Auto Layout constaints. The width and height of the view is determined automatically based on the size of its content - stars and text. Therefore, there is no need to set width/height constaints on the Cosmos view.\n\n## Using Cosmos in code\n\nAdd `import Cosmos` to your source code, unless you used the file setup method.\n\nYou can style and control Cosmos view from your code by creating an outlet in your view controller. Alternatively, one can  instantiate `CosmosView` class and add it to the view manually without using Storyboard.\n\n\n```Swift\n// Change the cosmos view rating\ncosmosView.rating = 4\n\n// Change the text\ncosmosView.text = \"(123)\"\n\n// Called when user finishes changing the rating by lifting the finger from the view.\n// This may be a good place to save the rating in the database or send to the server.\ncosmosView.didFinishTouchingCosmos = { rating in }\n\n// A closure that is called when user changes the rating by touching the view.\n// This can be used to update UI as the rating is being changed by moving a finger.\ncosmosView.didTouchCosmos = { rating in }\n```\n\n\n## Customization\n\nOne can customize Cosmos from code by changing its `settings`. See the [Cosmos configuration manual](https://github.com/evgenyneu/Cosmos/wiki/Cosmos-configuration) for the complete list of configuration options.\n\n```Swift\n// Do not change rating when touched\n// Use if you need just to show the stars without getting user's input\ncosmosView.settings.updateOnTouch = false\n\n// Show only fully filled stars\ncosmosView.settings.fillMode = .full\n// Other fill modes: .half, .precise\n\n// Change the size of the stars\ncosmosView.settings.starSize = 30\n\n// Set the distance between stars\ncosmosView.settings.starMargin = 5\n\n// Set the color of a filled star\ncosmosView.settings.filledColor = UIColor.orange\n\n// Set the border color of an empty star\ncosmosView.settings.emptyBorderColor = UIColor.orange\n\n// Set the border color of a filled star\ncosmosView.settings.filledBorderColor = UIColor.orange\n```\n\n\n\n## Supplying images for the stars\n\nBy default, Cosmos draws the stars from an array of points. Alternatively, one can supply custom images for the stars, both in the Storyboard and from code.\n\n#### Using star images from the Storyboard\n\n\u003cimg src='https://github.com/evgenyneu/Cosmos/raw/master/graphics/Screenshots/cosmos_ios_supplying_images_storyboard.png' width='514' alt='Supplying an image for a star in Xcode.'\u003e\n\n#### Using star images from code\n\n```Swift\n// Set image for the filled star\ncosmosView.settings.filledImage = UIImage(named: \"GoldStarFilled\")\n\n// Set image for the empty star\ncosmosView.settings.emptyImage = UIImage(named: \"GoldStarEmpty\")\n```\nNote: you need to have the images for the filled and empty star in your project for this code to work.\n\n#### Download star image files\n\nImages for the golden star used in the demo app are available in [here](https://github.com/evgenyneu/Cosmos/tree/master/graphics/Stars/GoldStar). Contributions for other star images are very welcome: add vector images to `/graphics/Stars/` directory and submit a pull request.\n\n\n## Using Cosmos in a scroll/table view\n\n[Here](https://github.com/evgenyneu/Cosmos/wiki/Using-Cosmos-in-a-scroll-view) is how to use Cosmos in a scroll view or a table view.\n\n\n## Using Cosmos with SwiftUI\n\n[Here](https://github.com/evgenyneu/Cosmos/wiki/Using-Cosmos-with-SwiftUI) is how to show a Cosmos view with SwiftUI.\n\n\n## Using Cosmos in a modal screen\n\niOS 13 introduced swiping gesture for closing modal screens, which [prevents Cosmos from working properly](https://github.com/evgenyneu/Cosmos/issues/148). The following setting fixes this problem:\n\n```\ncosmosView.settings.disablePanGestures = true\n```\n\n## Using Cosmos settings from Objective-C\n\n[This manual](https://github.com/evgenyneu/Cosmos/wiki/Using-Cosmos-settings-in-Objective-C) describes how to set/read Cosmos settings in Objective-C apps.\n\n\n## Demo app\n\nThis project includes a demo iOS app.\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Screenshots/cosmos_star_rating.gif' alt='Five star rating control for iOS written in Swift' width='250'\u003e\n\n#### Using cosmos in a table view\n\n\u003cimg src='https://raw.githubusercontent.com/evgenyneu/Cosmos/master/graphics/Screenshots/cosmos_star_rating_swift_performance.gif' alt='Using cosmos in a table view' width='250'\u003e\n\n\n\n## Alternative solutions\n\nHere are some other star rating controls for iOS:\n\n* [danwilliams64/DJWStarRatingView](https://github.com/danwilliams64/DJWStarRatingView)\n* [dlinsin/DLStarRating](https://github.com/dlinsin/DLStarRating)\n* [dyang/DYRateView](https://github.com/dyang/DYRateView)\n* [erndev/EDStarRating](https://github.com/erndev/EDStarRating)\n* [hugocampossousa/HCSStarRatingView](https://github.com/hugocampossousa/HCSStarRatingView)\n* [shuhrat10/STRatingControl](https://github.com/shuhrat10/STRatingControl)\n* [strekfus/FloatRatingView](https://github.com/strekfus/FloatRatingView)\n* [yanguango/ASStarRatingView](https://github.com/yanguango/ASStarRatingView)\n\n## Thanks 👍\n\nWe would like to thank the following people for their valuable contributions.\n\n* [jsahoo](https://github.com/jsahoo) for adding ability to customize the Cosmos view from the interface builder with Carthage setup method.\n* [0x7fffffff](https://github.com/0x7fffffff) for changing `public` access-level modifiers to `open`.\n* [ali-zahedi](https://github.com/ali-zahedi) for updating to the latest version of Swift 3.0.\n* [augmentedworks](https://github.com/augmentedworks) for adding borders to filled stars.\n* [craiggrummitt](https://github.com/craiggrummitt) for Xcode 8 beta 4 support.\n* [JimiSmith](https://github.com/JimiSmith) for Xcode 8 beta 6 support.\n* [nickhart](https://github.com/nickhart) for adding compatibility with Xcode 6.\n* [staticdreams](https://github.com/staticdreams) for bringing tvOS support.\n* [wagnersouz4](https://github.com/wagnersouz4) for Swift 3.1 update.\n* [paoloq](https://github.com/paoloq) for reporting the CosmoView frame size issue when the view is used without Auto Layout.\n* [danshevluk](https://github.com/danshevluk) for adding ability to reuse settings in multiple cosmos views.\n* [xrayman](https://github.com/xrayman) for reporting a table view reusability bug and improving the table view screen of the demo app.\n* [chlumik](https://github.com/chlumik) for updating to Swift 4.2.\n* [rebeloper](https://github.com/rebeloper) for creating a [video tutorial](https://www.youtube.com/watch?v=Y4A_y29cy7Q).\n* [yuravake](https://github.com/yuravake) for adding `passTouchesToSuperview` setting.\n* [gcharita](https://github.com/gcharita) for adding Swift Package Manager support.\n* [benpackard](https://github.com/benpackard) for fixing Cosmos when used in a modal screen on iOS 13.\n* [dkk](https://github.com/dkk) for the dark mode update.\n\n\n\n## License\n\nCosmos is released under the [MIT License](LICENSE).\n\n## 🌌⭐️🌕🚀🌠\n\n\u003e We are a way for the cosmos to know itself.\n\n*Carl Sagan, from 1980 \"Cosmos: A Personal Voyage\" TV series.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevgenyneu%2FCosmos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevgenyneu%2FCosmos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevgenyneu%2FCosmos/lists"}