抽取UIButton分类及UIBarButtonItem分类

  • 提供接口快速实现对button和barButtonItem的创建
  • 为了可扩展性和复用性,要有面向接口编程而不是面向实现编程

  • .h文件:

    @interface UIButton (WYButton)
    
    - (instancetype)initWithImage:(UIImage *)image selectedImage:(UIImage *)selectedImage addTarget:(id)target action:(SEL)action;
    
    - (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage addTarget:(id)target action:(SEL)action;
    
    + (instancetype)buttonWithImage:(UIImage *)image selectedImage:(UIImage *)selectedImage addTarget:(id)target action:(SEL)action;
    
    + (instancetype)buttonWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage addTarget:(id)target action:(SEL)action;
    
    @end
    
  • .h文件:

    @interface UIBarButtonItem (WYItem)
    
    + (instancetype)itemWithWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage addTarget:(id)target action:(SEL)action;
    
    + (instancetype)itemWithWithImage:(UIImage *)image selectedImage:(UIImage *)selectedImage addTarget:(id)target action:(SEL)action;
    
    @end
    

results matching ""

    No results matching ""