Skip to content

Instantly share code, notes, and snippets.

@alyssais
Created May 11, 2013 10:19
Show Gist options
  • Save alyssais/5559513 to your computer and use it in GitHub Desktop.
Save alyssais/5559513 to your computer and use it in GitHub Desktop.
Makes it easier to use custom UIButtons for the crappy UIBarButtonItems in a bar.
//
// UIBarButtonItem+CustomButton.h
//
// Created by Ross Penman on 11/05/2013.
// Copyright (c) 2013 Ross Penman. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIBarButtonItem (CustomButton)
- (void)setCustomButton:(UIButton *)button;
- (UIButton *)customButton;
@end
//
// UIBarButtonItem+CustomButton.m
//
// Created by Ross Penman on 11/05/2013.
// Copyright (c) 2013 Ross Penman. All rights reserved.
//
#import "UIBarButtonItem+CustomButton.h"
@implementation UIBarButtonItem (CustomButton)
- (void)setCustomButton:(UIButton *)button
{
self.customView = button;
[button addTarget:self.target action:self.action forControlEvents:UIControlEventTouchUpInside];
}
- (UIButton *)customButton
{
return (UIButton *)[self customView];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment