Note that there are some explanatory texts on larger screens.

plurals
  1. POCustomizing text style of UIBarButton held within a .xib
    primarykey
    data
    text
    <p>I have been developing apps for a few hours now. </p> <p>I am making a master-view detail app, from the template. The AppDelegate.m didFinishLaunchingWithOptions allows me to add some custom GUI code to alter things like nav bars and the like. So I went ahead and put a custom background in for the background of the main navigation bars, like this...</p> <pre><code>//custom navbar UIImage *navigationBarBackground = [UIImage imageNamed:@"NavigationBarBackground.png"]; [[UINavigationBar appearance] setBackgroundImage:navigationBarBackground forBarMetrics:UIBarMetricsDefault]; </code></pre> <p>Awesome! Now my navigation bars have custom bgs!</p> <p>Now in the master view area, I have a + button on the top right of the view, which when you click it, opens up a window over the rest of the content, but not a full screen, just a place to input some information, like a form. I created a new class with a .xib. I designed the new window from IB.</p> <p>But when the new window pops up, the nav bar is not my custom image, it is the default...</p> <p>So I spent hours trying to find a way to change this also. Finally I came up with adding a custom class to the UIToolbar, by making a new class that would make whatever navBar it was applied to, load a certain image into its background. Great! My .m file for that looks like this:</p> <pre><code>#import "customToolbar.h" //for your information the .h for this is a blank { } @implementation customToolbar - (void)drawRect:(CGRect)rect { CGContextRef c = UIGraphicsGetCurrentContext(); UIImage *image = [UIImage imageNamed:@"addBusKid-NavBar.png"]; CGContextDrawImage(c, rect, image.CGImage); } @end </code></pre> <p>So wonderful, with this class, I can apply any bg image to a navigation bar in interface builder.</p> <p>...</p> <p>Now, with my nav bars all looking nice, I decided it was time to change some text! So, I started back at my AppDelegate.m</p> <p>I added some code to change the default text styling of all navigation bar text...</p> <pre><code>// Customize the title text for *all* UINavigationBars [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"Arial-Bold" size:0.0], UITextAttributeFont, nil]]; </code></pre> <p>Great, this changes my navigation bar text styling...but wait, when I open up that pop up window I made with .xib, just like when I added navigationBar styling in AppDelegate, it did not affect its appearance. So whatever appearance protocols I make, they do not affect my custom classes xibs appearance...</p> <p>Well I tried to make a custom class just like I did for the navigation bar, that I could apply to give it some style. But I was unable to accomplish this (if you know please tell me)...</p> <p>And on I went for 3 + hours searching for some way to style the text within this .xib file! Nothing I put in AppDelegate touches it! </p> <p>So, having explained myself thoroughly to you. My question is thus:</p> <p>How do I style UIBarButton text that is created in interface builder.</p> <p>Whether you know of a custom class I could write, that I could then apply to the object as I did the navigation bar for this, or there is some way to add this .xibs UI elements to be stylized according to what I declare in AppDelegate. Please advise me. I have done my homework.</p> <p>By the way, this is my first post! I feel at home already! Thanks for your support, I hope I can likewise be of help to others.</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. 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