{"id":15030235,"url":"https://github.com/yalantis/persei","last_synced_at":"2025-05-15T00:06:57.374Z","repository":{"id":28211760,"uuid":"31715632","full_name":"Yalantis/Persei","owner":"Yalantis","description":"Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift","archived":false,"fork":false,"pushed_at":"2020-04-22T09:42:56.000Z","size":2370,"stargazers_count":3454,"open_issues_count":2,"forks_count":315,"subscribers_count":123,"default_branch":"master","last_synced_at":"2025-05-15T00:06:50.866Z","etag":null,"topics":["animation","carthage","cocoapods","custom","drag","ios","menu","navigator","persei","swift","uicollectionview","uiscrollview","uitableview"],"latest_commit_sha":null,"homepage":"https://yalantis.com/?utm_source=github","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/Yalantis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-05T13:43:30.000Z","updated_at":"2025-05-02T16:46:22.000Z","dependencies_parsed_at":"2022-08-02T15:45:18.327Z","dependency_job_id":null,"html_url":"https://github.com/Yalantis/Persei","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPersei","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPersei/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPersei/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPersei/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yalantis","download_url":"https://codeload.github.com/Yalantis/Persei/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249197,"owners_count":22039029,"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","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":["animation","carthage","cocoapods","custom","drag","ios","menu","navigator","persei","swift","uicollectionview","uiscrollview","uitableview"],"created_at":"2024-09-24T20:12:49.450Z","updated_at":"2025-05-15T00:06:57.338Z","avatar_url":"https://github.com/Yalantis.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Persei\n[![Build Status](https://travis-ci.org/Yalantis/Persei.svg)](https://travis-ci.org/Yalantis/Persei)\n[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/Yalantis/Persei/blob/master/LICENSE)\n\n![Preview](https://github.com/Yalantis/Persei/blob/master/Assets/animation.gif)\n\nAnimated top menu for UITableView / UICollectionView / UIScrollView written in Swift!\n\nMade in [Yalantis](https://yalantis.com/?utm_source=github).\n\nCheck this [project on Dribbble](https://dribbble.com/shots/1706861-Top-Menu-Animation?list=users\u0026offset=23)\n\nCheck this [project on Behance](https://www.behance.net/gallery/20411445/Mobile-Animations-Interactions%20)\n\n## Supported Swift versions\n\n| Swift Version | Persei |\n|:---:|:---:|\n| 1.x | 1.1 |\n| 2.x | 2.0 |\n| 3.x | 3.0 |\n| 4.x | 3.1|\n| **5.x** | **4.0** |\n\n## Installation\n\n### [CocoaPods](http://cocoapods.org)\n\n```ruby\nuse_frameworks!\n\npod 'Persei', '~\u003e 4.0'\n```\n\n### [Carthage](http://github.com/Carthage/Carthage)\n\n```ruby\ngithub \"Yalantis/Persei\" ~\u003e 4.0\n```\n\n### Manual Installation\n\u003e For application targets that do not support embedded frameworks, such as iOS 7, Persei can be integrated by including source files from the Persei folder directly, optionally wrapping the top-level types into `struct Persei` to simulate a namespace. Yes, this sucks.\n\n1. Add Persei as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the command `git submodule add https://github.com/yalantis/Persei.git`\n2. Open the `Persei` folder, and drag `Persei.xcodeproj` into the file navigator of your app project.\n3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the \"Targets\" heading in the sidebar.\n4. Ensure that the deployment target of `Persei.framework` matches that of the application target.\n5. In the tab bar at the top of that window, open the \"Build Phases\" panel.\n6. Expand the \"Target Dependencies\" group, and add `Persei.framework`.\n7. Expand the \"Link Binary With Libraries\" group, and add `SideMenu.framework`\n8. Click on the `+` button at the top left of the panel and select \"New Copy Files Phase\". Rename this new phase to \"Copy Frameworks\", set the \"Destination\" to \"Frameworks\", and add `Persei.framework`.\n\n## Usage\n#### Import `Persei` module\n```swift\nimport Persei\n```\n\n#### Init\n```swift\nlet menu = MenuView()    \ntableView.addSubview(menu)\n```\n\n#### Configuring items\nIn order to set items you need to instantiate array of `MenuItem`:\n\n```swift\nlet items = feedModes.map { mode: SomeYourCustomFeedMode -\u003e MenuItem in\n\treturn MenuItem(image: mode.image)\n}\n\nmenu.items = items\n```\n\n#### Handling selection\nYou can specify selected item manually:\n```swift\nmenu.selectedIndex = 3\n```\n\nNote, that selectedIndex declared as `Int?` and will be `nil` in case of `menu.items = nil`.\n\nAlso, you can implement `MenuViewDelegate` to be notified about selection change:\n```swift\n// during init\nmenu.delegate = self\n\n// actual implementation\nextension FeedViewController: MenuViewDelegate {\n    func menu(menu: MenuView, didSelectItemAt index: Int) {\n    \tdataSource.mode = feedModes[index] // alter mode of dataSource\n\n    \ttableView.reload() // update tableView\n    }\n}\n```\n\n#### Reveal menu manually\nMenu can be reveal as a result of button tap:\n```swift\nfunc menuButtonSelected(sender: UIControl) {\n\tmenu.revealed = !menu.revealed\n\n\t// or animated\n\tmenu.setRevealed(true, animated: true)\n}\n```\n\n#### Content Gravity\nUse `contentViewGravity` to control sticking behavior. There are 3 available options:\n\n- Top: `contentView` sticked to the top position of the view\n- Center: `contentView` is aligned to the middle of the streched view\n- Bottom: `contentView` sticked to the bottom\n\n#### Customization\n`MenuItem` declares set of attributes, that allow you to customize appearance of items:\n```swift\nstruct MenuItem {\n    var image: UIImage // default image\n    var highlightedImage: UIImage? // image used during selection\n\n    var backgroundColor: UIColor // default background color\n    var highlightedBackgroundColor: UIColor // background color used during selection\n\n    var shadowColor: UIColor // color of bottom 2px shadow line\n}\n```\n\nAlso you're free to configure background of `MenuView` by utilizing `backgroundColor` or `backgroundImage`. Note, that image should be resizeable:\n```swift\nlet menu = MenuView()\nmenu.backgroundImage = UIImage(named: \"top_menu_background\")\n```\n\n#### Advanced customization\n- Can I place the UIImageView instead?\n- Sure! Just subclass / use `StickyHeaderView` directly. It offers layout, positioning and reveal control. All you have to do is to assign your custom view (animated nian-cat UIImageView) to `contentView`:\n\n```swift\nlet headerView = StickyHeaderView()\nlet imageView = UIImageView(...)\n\nheaderView.contentView = imageView\n```\n\nObviously, your custom view can have heigh different from default:\n```swift\nheaderView.contentHeight = image.size.height\n```\n\nAs well as control distance to trigger open/close of the header:\n```swift\nheaderView.threshold = 0.5\n```\nThreshold is a float value from 0 to 1, specifies how much user needs to drag header for reveal.\n\n#### Let us know!\n\nWe’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.\n\nP.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!\n\n## License\n\n\tThe MIT License (MIT)\n\n\tCopyright © 2017 Yalantis\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalantis%2Fpersei","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyalantis%2Fpersei","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalantis%2Fpersei/lists"}