Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>for IOS5*</strong></p> <p>The only way I found is using a UIBarButtonItem category:</p> <p>UIBarButtonItem+Appearance.h</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface UIBarButtonItem (Appearance) + (void) setupAppearance; @end </code></pre> <p>UIBarButtonItem+Appearance.m</p> <pre><code>#import "UIBarButtonItem+Appearance.h" #import &lt;objc/runtime.h&gt; @implementation UIBarButtonItem (Appearance) + (void) setupAppearance { [[UIBarButtonItem appearance] setBackgroundImage: [[UIImage imageNamed:@"customButton"] resizableImageWithCapInsets: UIEdgeInsetsMake(8, 8, 8, 8)] forState: UIControlStateNormal barMetrics: UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackgroundImage: [[UIImage imageNamed:@"customButtonHiglhighted"] resizableImageWithCapInsets: UIEdgeInsetsMake(8, 8, 8, 8)] forState: UIControlStateHighlighted barMetrics: UIBarMetricsDefault]; Class klass = objc_getClass("UIBarButtonItem"); Method targetMethod = class_getInstanceMethod(klass, @selector(setStyle:)); Method newMethod = class_getInstanceMethod(klass, @selector(__setStyle:)); method_exchangeImplementations(targetMethod, newMethod); } - (void) __setStyle:(UIBarButtonItemStyle)style { [self __setStyle:style]; if(style == UIBarButtonItemStyleDone) { [self setBackgroundImage:[[UIImage imageNamed:@"customDoneButton"] resizableImageWithCapInsets: UIEdgeInsetsMake(8, 8, 8, 8)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [self setBackgroundImage:[UIImage imageNamed:@"customDoneButtonClicked"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; } else { [self setBackgroundImage:[[UIImage imageNamed:@"customButton"] resizableImageWithCapInsets: UIEdgeInsetsMake(8, 8, 8, 8)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [self setBackgroundImage:[UIImage imageNamed:@"customButtonHighlighted"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; } } @end </code></pre> <p>Hope this is what you are looking for. Credit for this solution goes to <a href="https://gist.github.com/2633081" rel="noreferrer">https://gist.github.com/2633081</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload