Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Last active December 14, 2015 16:19
Show Gist options
  • Save chrisallick/5114633 to your computer and use it in GitHub Desktop.
Save chrisallick/5114633 to your computer and use it in GitHub Desktop.
Custom UIView with Background Image and Navigation Bar.
//
// SettingsView.m
// lastapp
//
// Created by Christopher Allick on 3/5/13.
// Copyright (c) 2013 Goon & Goblin. All rights reserved.
//
#import "SettingsView.h"
@implementation SettingsView
@synthesize bg;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
bg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"settings_bg.png"]];
[bg setFrame:CGRectMake(0.0, 0.0, self.frame.size.width, self.frame.size.height)];
[self addSubview:bg];
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain target:self action:@selector(dismiss:)];
UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Settings"];
item.hidesBackButton = YES;
item.rightBarButtonItem = rightButton;
[item.leftBarButtonItem setEnabled:YES];
[navBar pushNavigationItem:item animated:YES];
[navBar setBarStyle:UIBarStyleBlack];
[self addSubview:navBar];
}
return self;
}
-(void)dismiss:(id)sender {
NSLog(@"cool");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment