QBPopupMenuItem.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // QBPopupMenuItem.m
  3. // QBPopupMenu
  4. //
  5. // Created by Tanaka Katsuma on 2013/11/22.
  6. // Copyright (c) 2013年 Katsuma Tanaka. All rights reserved.
  7. //
  8. #import "QBPopupMenuItem.h"
  9. @interface QBPopupMenuItem ()
  10. @property (nonatomic, weak, readwrite) id target;
  11. @property (nonatomic, assign, readwrite) SEL action;
  12. @property (nonatomic, copy, readwrite) NSString *title;
  13. @property (nonatomic, copy, readwrite) UIImage *image;
  14. @end
  15. @implementation QBPopupMenuItem
  16. + (instancetype)itemWithTitle:(NSString *)title target:(id)target action:(SEL)action
  17. {
  18. return [[self alloc] initWithTitle:title target:target action:action];
  19. }
  20. + (instancetype)itemWithImage:(UIImage *)image target:(id)target action:(SEL)action
  21. {
  22. return [[self alloc] initWithImage:image target:target action:action];
  23. }
  24. + (instancetype)itemWithTitle:(NSString *)title image:(UIImage *)image target:(id)target action:(SEL)action
  25. {
  26. return [[self alloc] initWithTitle:title image:image target:target action:action];
  27. }
  28. - (instancetype)initWithTitle:(NSString *)title target:(id)target action:(SEL)action
  29. {
  30. return [self initWithTitle:title image:nil target:target action:action];
  31. }
  32. - (instancetype)initWithImage:(UIImage *)image target:(id)target action:(SEL)action
  33. {
  34. return [self initWithTitle:nil image:image target:target action:action];
  35. }
  36. - (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image target:(id)target action:(SEL)action
  37. {
  38. self = [super init];
  39. if (self) {
  40. self.target = target;
  41. self.action = action;
  42. self.title = title;
  43. self.image = image;
  44. }
  45. return self;
  46. }
  47. @end