{"id":21092389,"url":"https://github.com/ripperhe/zytagview","last_synced_at":"2025-05-16T13:32:39.718Z","repository":{"id":107991733,"uuid":"69848504","full_name":"ripperhe/ZYTagView","owner":"ripperhe","description":"仿微博图片添加标签","archived":false,"fork":false,"pushed_at":"2020-02-10T08:44:54.000Z","size":569,"stargazers_count":164,"open_issues_count":3,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T02:11:06.809Z","etag":null,"topics":["ios","objective-c","tag","weibo"],"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/ripperhe.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-10-03T07:13:00.000Z","updated_at":"2024-03-28T10:05:41.000Z","dependencies_parsed_at":"2023-05-15T17:15:30.333Z","dependency_job_id":null,"html_url":"https://github.com/ripperhe/ZYTagView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripperhe%2FZYTagView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripperhe%2FZYTagView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripperhe%2FZYTagView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripperhe%2FZYTagView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripperhe","download_url":"https://codeload.github.com/ripperhe/ZYTagView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254538535,"owners_count":22087883,"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":["ios","objective-c","tag","weibo"],"created_at":"2024-11-19T21:53:52.938Z","updated_at":"2025-05-16T13:32:38.813Z","avatar_url":"https://github.com/ripperhe.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZYTagView\n\n公司的项目需要这个功能，写了之后顺便提取出来写了一个 demo，简单实现图片添加标签，暂时没有去处理图片宽度小于标签长度的情况。\n\n## 效果图\n\n![](https://raw.githubusercontent.com/ripperhe/oss/master/2016/1228/tagview.gif)\n\n## 类介绍\n\n![](./zytagimageview_class.png)\n\n主要有三个类\n\n1. ZYTagImageView \n\n\t继承自 `UIImageView` ，主要处理其上的所有标签\n\n2. ZYTagView \n\n\t继承自 `UIView` ，标签视图，处理标签的各种手势，并利用代理进行回调\n\n3. ZYTagInfo\n\n\t继承自 `NSObject`，存储标签的信息，可存储具体位置以及当前点在父视图的位置比例（建议使用位置比例，在不同尺寸的屏幕上才能正常显示）\n\t\n一个 `ZYTagImageView` 可以添加多个 `ZYTagView`，每个 `ZYTagView` 对应着一个 `ZYTagInfo`，所有标签位置信息均存储在 `ZYTagInfo` 中。\n\n## 标签交互\n\n类似微博的图片添加标签分为两种状态，一种是编辑标签状态，另一种是微博发出之后浏览其他人添加的标签的浏览状态。\n\n### 编辑状态\n\n添加标签拖动交互主要有以下几个点：\n\n1. 拖动边界控制\n\n\t根据圆点的位置进行限制拖动\n\n2. 边界标签方向翻转\n\n\t在拖动手势状态为 `UIGestureRecognizerStateEnded` 时候，检测是否能够放下删除按钮，不能则进行反向\n\n3. 轻触显示与隐藏删除按钮\n\n\t默认轻触标签显示和隐藏删除按钮，此时重新布局标签子控件位置；在拖动手势开始的时候，隐藏删除按钮\n\n4. 长按编辑标签\n\n\t遵守代理，即可获取到当前标签数据，进行修改\n\n5. 闪烁动画\n\n\t利用一个帧动画简单实现闪烁，根据传入的 `repeatCount` 决定动画闪烁多久\n\n### 预览状态\n\n供他人浏览，不可编辑，利用代理模式回调标签的轻触和长按手势。\n\n## 简单使用\n\n导入 `#import \"ZYTagImageView.h\"` \n\n初始化 `ZYTagImageView `\n\n```objc\nZYTagImageView *imageView = [[ZYTagImageView alloc] initWithImage:image];\nimageView.delegate = self;\nimageView.frame = CGRectMake(100, 100, 100, 100);\n[self.view addSubview:imageView];\n```\n\n添加一个标签\n\n```objc\n[imageView addTagWithTitle:@\"我是一个标签\" point:CGPointMake(30, 40) object:nil];\n```\n\n删除所有标签\n\n```objc\n[imageView removeAllTags];\n```\n\n设置为预览模式\n\n```objc\n[imageView setAllTagsEditEnable:NO];\n```\n\n自定义手势处理，需遵守 `ZYTagImageViewDelegate`，实现以下代理方法\n\n```objc\n/** 轻触imageView空白区域 */\n- (void)tagImageView:(ZYTagImageView *)tagImageView activeTapGesture:(UITapGestureRecognizer *)tapGesture;\n/** 轻触标签 */\n- (void)tagImageView:(ZYTagImageView *)tagImageView tagViewActiveTapGesture:(ZYTagView *)tagView;\n/** 长按标签 */\n- (void)tagImageView:(ZYTagImageView *)tagImageView tagViewActiveLongPressGesture:(ZYTagView *)tagView;\n```\n\n更多用法下载 demo 查看~","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripperhe%2Fzytagview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripperhe%2Fzytagview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripperhe%2Fzytagview/lists"}