{"id":13696343,"url":"https://github.com/iceyouyou/UUMarqueeView","last_synced_at":"2025-05-03T17:30:53.881Z","repository":{"id":41329872,"uuid":"75914460","full_name":"iceyouyou/UUMarqueeView","owner":"iceyouyou","description":"[iOS]Customizable marquee view. #Marquee,MarqueeView,跑马灯,滚屏,上翻,左滑,多行,自定义","archived":false,"fork":false,"pushed_at":"2019-06-24T07:13:32.000Z","size":3037,"stargazers_count":361,"open_issues_count":1,"forks_count":47,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-13T00:32:43.655Z","etag":null,"topics":["customizable","ios","marquee","right-to-left","scroll","view"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/iceyouyou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-08T07:34:12.000Z","updated_at":"2024-11-05T03:49:57.000Z","dependencies_parsed_at":"2022-08-26T04:20:36.153Z","dependency_job_id":null,"html_url":"https://github.com/iceyouyou/UUMarqueeView","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iceyouyou%2FUUMarqueeView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iceyouyou%2FUUMarqueeView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iceyouyou%2FUUMarqueeView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iceyouyou%2FUUMarqueeView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iceyouyou","download_url":"https://codeload.github.com/iceyouyou/UUMarqueeView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252226635,"owners_count":21714835,"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":["customizable","ios","marquee","right-to-left","scroll","view"],"created_at":"2024-08-02T18:00:38.657Z","updated_at":"2025-05-03T17:30:53.577Z","avatar_url":"https://github.com/iceyouyou.png","language":"Objective-C","funding_links":[],"categories":["UI Components"],"sub_categories":[],"readme":"# UUMarqueeView\n[![Build Status](https://travis-ci.org/iceyouyou/UUMarqueeView.svg?branch=master)](https://travis-ci.org/iceyouyou/UUMarqueeView)\n\nCustomizable marquee view for iOS. [Usage in English](#usage) / [中文使用方法](#使用方法)\n\n## Demo\n![UUMarqueeView](https://raw.githubusercontent.com/iceyouyou/UUMarqueeView/master/extra/demo.gif)\n\n## Revision History\n- 2018/08/15 - Add dynamic height support\n- 2018/05/16 - Add leftward scrolling support\n- 2017/06/20 - Add touch event handler\n- 2016/12/08 - Basic marquee view function\n\n## Usage\nThere are two scroll directions for a marquee view:\n```objective-c\nUUMarqueeViewDirectionUpward,   // scroll from bottom to top\nUUMarqueeViewDirectionLeftward  // scroll from right to left\n```\n\nCreate a upward scrolling marquee view by:\n```objective-c\nself.marqueeView = [[UUMarqueeView alloc] initWithFrame:CGRectMake(20.0f, 40.0f, 100.0f, 20.0f)];\nself.marqueeView.delegate = self;\nself.marqueeView.timeIntervalPerScroll = 2.0f;\nself.marqueeView.timeDurationPerScroll = 1.0f;\nself.marqueeView.touchEnabled = YES;\t// Set YES if you want to handle touch event. Default is NO.\n[self.view addSubview:self.marqueeView];\n[self.marqueeView reloadData];\n```\n\nOr a leftward scrolling marquee view by:\n```objective-c\nself.marqueeView = [[UUMarqueeView alloc] initWithFrame:CGRectMake(20.0f, 40.0f, 100.0f, 20.0f) direction:UUMarqueeViewDirectionLeftward];\nself.marqueeView.delegate = self;\nself.marqueeView.timeIntervalPerScroll = 0.0f;\nself.marqueeView.scrollSpeed = 60.0f;\nself.marqueeView.itemSpacing = 20.0f;\t// the minimum spacing between items\nself.marqueeView.touchEnabled = YES;\t// Set YES if you want to handle touch event. Default is NO.\n[self.view addSubview:self.marqueeView];\n[self.marqueeView reloadData];\n```\n\nThen implement `UUMarqueeViewDelegate` protocol:\n```objective-c\n@protocol UUMarqueeViewDelegate \u003cNSObject\u003e\n- (NSUInteger)numberOfDataForMarqueeView:(UUMarqueeView*)marqueeView;\n- (void)createItemView:(UIView*)itemView forMarqueeView:(UUMarqueeView*)marqueeView;\n- (void)updateItemView:(UIView*)itemView atIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;\n@optional\n- (NSUInteger)numberOfVisibleItemsForMarqueeView:(UUMarqueeView*)marqueeView;   // only for [UUMarqueeViewDirectionUpward]\n- (CGFloat)itemViewWidthAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;   // only for [UUMarqueeViewDirectionLeftward]\n- (void)didTouchItemViewAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;\n@end\n```\n\nSample code:\n```objective-c\n- (NSUInteger)numberOfVisibleItemsForMarqueeView:(UUMarqueeView*)marqueeView {\n    // this will be called only when direction is [UUMarqueeViewDirectionUpward].\n    // set a row count that you want to display.\n    return 1;\n}\n\n- (NSUInteger)numberOfDataForMarqueeView:(UUMarqueeView*)marqueeView {\n    // the count of data source array.\n    // For example: if data source is @[@\"A\", @\"B\", @\"C\"]; then return 3.\n    return 3;\n}\n\n- (void)createItemView:(UIView*)itemView forMarqueeView:(UUMarqueeView*)marqueeView {\n    // add any subviews you want but do not set any content.\n    // this will be called to create every row view in '-(void)reloadData'.\n    // ### give a tag on all of your changeable subviews then you can find it later('-(void)updateItemView:withData:forMarqueeView:').\n    UILabel *content = [[UILabel alloc] initWithFrame:itemView.bounds];\n    content.font = [UIFont systemFontOfSize:10.0f];\n    content.tag = 1001;\n    [itemView addSubview:content];\n}\n\n- (void)updateItemView:(UIView*)itemView atIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // set content to subviews, this will be called on each time the MarqueeView scrolls.\n    // 'index' is the index of data source array.\n    UILabel *content = [itemView viewWithTag:1001];\n    content.text = dataSource[index];\n}\n\n- (CGFloat)itemViewWidthAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // this will be called only when direction is [UUMarqueeViewDirectionLeftward].\n    // give the width of item view when the data source setup.\n    // ### is good to cache the width once and reuse it in next time. if you do so, remember to clear the cache when you chang the data source array.\n    UILabel *content = [[UILabel alloc] init];\n    content.font = [UIFont systemFontOfSize:10.0f];\n    content.text = dataSource[index];\n    return content.intrinsicContentSize.width;\n}\n\n- (void)didTouchItemViewAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // if 'touchEnabled' is 'YES', this will call back when touch on the item view.\n    // if you ever changed data source array, becareful in using the index.\n    NSLog(@\"Touch at index %lu\", (unsigned long)index);\n}\n```\n\n## 使用方法\nmarquee view可以指定两种滑动方向:\n```objective-c\nUUMarqueeViewDirectionUpward,   // 从下向上\nUUMarqueeViewDirectionLeftward  // 从右向左\n```\n\n可通过以下代码创建一个[从下向上]滑动的marquee view:\n```objective-c\nself.marqueeView = [[UUMarqueeView alloc] initWithFrame:CGRectMake(20.0f, 40.0f, 100.0f, 20.0f)];\nself.marqueeView.delegate = self;\nself.marqueeView.timeIntervalPerScroll = 2.0f;\t// 条目滑动间隔\nself.marqueeView.timeDurationPerScroll = 1.0f;\t// 条目滑动时间\nself.marqueeView.touchEnabled = YES;\t// 设置为YES可监听点击事件，默认值为NO\n[self.view addSubview:self.marqueeView];\n[self.marqueeView reloadData];\n```\n\n或以下代码创建一个[从右向左]滑动的marquee view:\n```objective-c\nself.marqueeView = [[UUMarqueeView alloc] initWithFrame:CGRectMake(20.0f, 40.0f, 100.0f, 20.0f) direction:UUMarqueeViewDirectionLeftward];\nself.marqueeView.delegate = self;\nself.marqueeView.timeIntervalPerScroll = 0.0f;\t// 条目滑动间隔\nself.marqueeView.scrollSpeed = 60.0f;\t// 滑动速度\nself.marqueeView.itemSpacing = 20.0f;\t// 左右相邻两个条目的间距，当左侧条目内容的长度超出marquee view整体长度时有效\nself.marqueeView.touchEnabled = YES;\t// 设置为YES可监听点击事件，默认值为NO\n[self.view addSubview:self.marqueeView];\n[self.marqueeView reloadData];\n```\n\n实现 `UUMarqueeViewDelegate` protocol:\n```objective-c\n@protocol UUMarqueeViewDelegate \u003cNSObject\u003e\n- (NSUInteger)numberOfDataForMarqueeView:(UUMarqueeView*)marqueeView;   // 数据源个数\n- (void)createItemView:(UIView*)itemView forMarqueeView:(UUMarqueeView*)marqueeView;   // 创建初始条目视图\n- (void)updateItemView:(UIView*)itemView atIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;   // 更新条目内容\n@optional\n- (NSUInteger)numberOfVisibleItemsForMarqueeView:(UUMarqueeView*)marqueeView;   // 可视条目数量，仅[UUMarqueeViewDirectionUpward]时被调用\n- (CGFloat)itemViewWidthAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;   // 条目显示指定内容后的宽度，仅[UUMarqueeViewDirectionLeftward]时被调用\n- (void)didTouchItemViewAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView;   // 点击事件回调\n@end\n```\n\nprotocol示例代码:\n```objective-c\n- (NSUInteger)numberOfVisibleItemsForMarqueeView:(UUMarqueeView*)marqueeView {\n    // 指定可视条目的行数，仅[UUMarqueeViewDirectionUpward]时被调用。\n    // 当[UUMarqueeViewDirectionLeftward]时行数固定为1。\n    return 1;\n}\n\n- (NSUInteger)numberOfDataForMarqueeView:(UUMarqueeView*)marqueeView {\n    // 指定数据源的个数。例:数据源是字符串数组@[@\"A\", @\"B\", @\"C\"]时，return 3。\n    return 3;\n}\n\n- (void)createItemView:(UIView*)itemView forMarqueeView:(UUMarqueeView*)marqueeView {\n    // 在marquee view创建时（即'-(void)reloadData'调用后），用于创建条目视图的初始结构，可自行添加任意subview。\n    // ### 给必要的subview添加tag，可在'-(void)updateItemView:withData:forMarqueeView:'调用时快捷获取并设置内容。\n    UILabel *content = [[UILabel alloc] initWithFrame:itemView.bounds];\n    content.font = [UIFont systemFontOfSize:10.0f];\n    content.tag = 1001;\n    [itemView addSubview:content];\n}\n\n- (void)updateItemView:(UIView*)itemView atIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // 设定即将显示的条目内容，在每次marquee view滑动时被调用。\n    // 'index'即为数据源数组的索引值。\n    UILabel *content = [itemView viewWithTag:1001];\n    content.text = dataSource[index];\n}\n\n- (CGFloat)itemViewWidthAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // 指定条目在显示数据源内容时的视图宽度，仅[UUMarqueeViewDirectionLeftward]时被调用。\n    // ### 在数据源不变的情况下，宽度可以仅计算一次并缓存复用。\n    UILabel *content = [[UILabel alloc] init];\n    content.font = [UIFont systemFontOfSize:10.0f];\n    content.text = dataSource[index];\n    return content.intrinsicContentSize.width;\n}\n\n- (void)didTouchItemViewAtIndex:(NSUInteger)index forMarqueeView:(UUMarqueeView*)marqueeView {\n    // 点击事件回调。在'touchEnabled'设置为YES后，触发点击事件时被调用。\n    NSLog(@\"Touch at index %lu\", (unsigned long)index);\n}\n```\n\n## Compatibility\n- Requires ARC.\n- Supports iOS7+.\n\n## License\n`UUMarqueeView` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficeyouyou%2FUUMarqueeView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficeyouyou%2FUUMarqueeView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficeyouyou%2FUUMarqueeView/lists"}