{"id":18270539,"url":"https://github.com/cxa/UIMenuItem-CXAImageSupport","last_synced_at":"2025-04-05T01:30:40.274Z","repository":{"id":6181036,"uuid":"7411290","full_name":"cxa/UIMenuItem-CXAImageSupport","owner":"cxa","description":"[Deprecated! Use MenuItemKit instead] UIMenuItem with Image Support","archived":false,"fork":false,"pushed_at":"2016-06-08T05:24:32.000Z","size":484,"stargazers_count":335,"open_issues_count":4,"forks_count":36,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-18T16:26:17.931Z","etag":null,"topics":[],"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/cxa.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":"2013-01-02T18:30:24.000Z","updated_at":"2024-06-17T13:17:32.000Z","dependencies_parsed_at":"2022-09-01T22:02:57.963Z","dependency_job_id":null,"html_url":"https://github.com/cxa/UIMenuItem-CXAImageSupport","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FUIMenuItem-CXAImageSupport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FUIMenuItem-CXAImageSupport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FUIMenuItem-CXAImageSupport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FUIMenuItem-CXAImageSupport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cxa","download_url":"https://codeload.github.com/cxa/UIMenuItem-CXAImageSupport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276022,"owners_count":20912285,"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":[],"created_at":"2024-11-05T11:38:42.253Z","updated_at":"2025-04-05T01:30:39.928Z","avatar_url":"https://github.com/cxa.png","language":"Objective-C","funding_links":[],"categories":["etc"],"sub_categories":[],"readme":"# UIMenuItem with Image Support\n\n*Officially Deprecated! use [MenuItemKit](https://github.com/cxa/MenuItemKit) instead.*\n\n![screenshot of UIMenuItem with image](screenshot.jpg)\n\n`UIMenuItem` uses `UILabel` to display its title, that means we can swizzle `-drawTextInRect:` to support image.\n\n`UIMenuItem+CXAImageSupport` is a dirty hack but should be safe in most cases. Contains no any private APIs and should be safe for App Store.\n\n## How to use\n\n*Xcode 7 required due to Objective-C generics.*\n\nDrag `UIMenuItem+CXAImageSupport.{h,m}` to your project. Or drag `ImageMenuItem.xcodeproj` to your project and embed `ImageMenuItem` framework if you only support iOS 8.0 and above.\n\nThe method names describe all. For simple usage, the only step is to set a image to the menu item. For advance usage, config and set a `settings`.\n\n    @class CXAMenuItemSettings;\n    \n    @interface UIMenuItem (CXAImageSupport)\n    \n    - (instancetype)initWithTitle:(NSString *)title action:(SEL)action image:(UIImage *)image;\n    - (instancetype)initWithTitle:(NSString *)title action:(SEL)action settings:(CXAMenuItemSettings *)settings;\n    - (void)cxa_setImage:(UIImage *)image;\n    - (void)cxa_setSettings:(CXAMenuItemSettings *)settings;\n    \n    @end\n    \n    // Uses a settings class instead of NSDictionary to avoid\n       misspelled keys\n    @interface CXAMenuItemSettings : NSObject \u003cNSCopying\u003e\n\n    + (instancetype)settingsWithDictionary:(NSDictionary\u003cNSString *, id\u003e *)dict;\n    \n    @property (nonatomic, strong) UIImage *image;\n    @property (nonatomic) BOOL shadowDisabled;\n    @property (nonatomic, strong) UIColor * __nullable shadowColor; // Default is [[UIColor blackColor] colorWithAlphaComponent:1./3.]\n    @property (nonatomic) CGFloat shrinkWidth; // For adjustment item width only, will not be preciouse because menu item will keep its minimun width, it's useful for showing some large amount of menu items without expanding.\n    \n    @end\n    \n## Limitation\n\n`UIMenuItem+CXAImageSupport` uses `UIMenuItem`'s title to map related image since there is no any other clue of `UIMenuItem` I can find to connect to `UILabel`. You can't set different images for the same title.\n\n## About Me\n\n* Twitter: [@_cxa](https://twitter.com/_cxa)\n* Apps available in App Store: \u003chttp://lazyapps.com\u003e\n* PayPal: xianan.chen+paypal 📧 gmail.com, buy me a cup of coffee if you find it's useful for you.\n\n## License\n\n`UIMenuItem+CXAImageSupport` is released under the MIT license. In short, it's royalty-free but you must keep the copyright notice in your code or software distribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2FUIMenuItem-CXAImageSupport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxa%2FUIMenuItem-CXAImageSupport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2FUIMenuItem-CXAImageSupport/lists"}