站内导读
中文 AZExpandableIconListView 是一个 iOS 开源 UIView 组件,用 UIImageView 数组实现手风琴式展开与收起。它解决图标列表在有限空间内的收纳与展示问题,基于 auto layout 与动画实现。图标尺寸固定为容器高度的 80%,可配置 imageSpacing 及展开、收起回调。适合需要可折叠图标菜单的 Swift 开发者,支持 iOS 11 以上,经 CocoaPods 安装。
日本語 AZExpandableIconListView は UIImageView の配列をアコーディオン状に展開・収納できる iOS 用 UIView コンポーネントです。限られた領域でアイコン一覧を整理して見せる課題に対し、Auto Layout とアニメーションで対応します。アイコンは常にコンテナ高さの80%で、imageSpacing と展開・収納時のコールバックを設定可能。Swift で折りたたみ式アイコンメニューを作る開発者向けで、iOS 11 以降に対応し CocoaPods で導入できます。
한국어 AZExpandableIconListView는 UIImageView 배열을 아코디언처럼 펼치고 접을 수 있는 iOS용 UIView 컴포넌트입니다. 좁은 공간에서 아이콘 목록을 정리해 보여주는 문제를 Auto Layout과 애니메이션으로 해결합니다. 아이콘 크기는 항상 컨테이너 높이의 80%이며 imageSpacing과 펼침·접힘 콜백을 설정할 수 있습니다. Swift로 접이식 아이콘 메뉴를 만드는 개발자에게 적합하고 iOS 11 이상에서 동작하며 CocoaPods로 설치합니다.
English AZExpandableIconListView is an iOS UIView component that expands and collapses an array of UIImageView like an accordion. It addresses the problem of fitting an icon list into limited space using auto layout and animation. Icon size is always 80% of the container height, and imageSpacing plus onExpanded and onCollapsed callbacks are configurable. It suits Swift developers building collapsible icon menus, runs on iOS 11 or later, and installs via CocoaPods.
README · 详细文档
来源 · 查看原文
AZExpandableIconListView
An expandable/collapsible UIView that holds an array of UIImageView. Something like accordion. An interesting practice with auto layout and animation.
Screenshots

Requirements
- iOS 11 or above
- Xcode 11 or above
- Swift 5
Demo Project
To run the example project, clone the repo with git clone https://github.com/Azuritul/AZExpandableIconListView.git, and run pod install from the Example directory first.
Usage
Initialize the view with frame and an array of images, for example:
let expandable = AZExpandableIconListView(frame: CGRectMake(4, 30, UIScreen.mainScreen().bounds.size.width - 20, 70), images: [image1, image2, image3])
view.addSubview(expandable)
Notice that the width and height of the icons in the view would always be 80% of the containing view's height.
Configurable options
Currently AZExpandableIconListView can be customized with the following properties. More will come in the future.
imageSpacingThe space between icons. Default is 4.onExpandedThe method to be called when the menu is expanded. Default is null.onCollapsedThe method to be called when the menu is collapsed. Default is null.
Installation
AZExpandableIconListView is available through CocoaPods. To install it, simply add the following line to your Podfile:
use_frameworks!
pod 'AZExpandableIconListView'
Version
- 1.0.1
- Fix lint warning
- 1.0.0
- Updated for Swift 5
- 0.2.0
- Updated for Swift 3
- 0.1.1
- Updated README
- 0.1.0
- Initial version
Credit
- Avatar icon used in README's screenshot is Designed by Skydesign - Freepik.com
Author
Chris Wu (Azuritul), azuritul@gmail.com
License
AZExpandableIconListView is available under the MIT license. See the LICENSE file for more info.