Skip to content

Commit

Permalink
Added crisper banner art
Browse files Browse the repository at this point in the history
  • Loading branch information
TimOliver committed Feb 10, 2018
1 parent 90db20b commit 9073fe8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
17 changes: 16 additions & 1 deletion TONavigationBar/TOHeaderImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ - (instancetype)initWithImage:(UIImage *)image height:(CGFloat)height
{
CGRect frame = (CGRect){0.0f, 0.0f, 320.0f, height};
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor blackColor];
self.contentMode = UIViewContentModeScaleAspectFill;
_image = image;
_shadowHeight = 100.0f;
_shadowHidden = YES;
_shadowAlpha = 0.4f;
_shadowAlpha = 0.2f;
_shadowIsDirty = YES;
[self setUpViews];
}
Expand All @@ -39,6 +41,7 @@ - (void)setUpViews
self.imageView = [[UIImageView alloc] initWithImage:_image];
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.clipsToBounds = YES;
self.imageView.backgroundColor = [UIColor blackColor];
[self addSubview:self.imageView];

self.gradientView = [[UIImageView alloc] initWithImage:nil];
Expand Down Expand Up @@ -120,6 +123,18 @@ - (void)setShadowHidden:(BOOL)shadowHidden
[self setNeedsLayout];
}

- (void)setBackgroundColor:(UIColor *)backgroundColor
{
[super setBackgroundColor:backgroundColor];
self.imageView.backgroundColor = backgroundColor;
}

- (void)setContentMode:(UIViewContentMode)contentMode
{
[super setContentMode:contentMode];
self.imageView.contentMode = contentMode;
}

+ (UIImage *)shadowImageForHeight:(CGFloat)height alpha:(CGFloat)alpha
{
UIImage *shadowImage = nil;
Expand Down
8 changes: 4 additions & 4 deletions TONavigationBarExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
222D3A79202187FA0015D098 /* TONavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 222D3A78202187FA0015D098 /* TONavigationBar.m */; };
222D3A7C20218D540015D098 /* SubViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 222D3A7B20218D540015D098 /* SubViewController.m */; };
2281FE4C202E071300D47FE2 /* TOHeaderImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2281FE4B202E071300D47FE2 /* TOHeaderImageView.m */; };
2281FE4E202E12F600D47FE2 /* Perth.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2281FE4D202E12F600D47FE2 /* Perth.jpg */; };
22AAB34A202E984E00B9B39D /* OK.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 22AAB349202E984E00B9B39D /* OK.jpg */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -34,7 +34,7 @@
222D3A7B20218D540015D098 /* SubViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SubViewController.m; sourceTree = "<group>"; };
2281FE4A202E071300D47FE2 /* TOHeaderImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TOHeaderImageView.h; sourceTree = "<group>"; };
2281FE4B202E071300D47FE2 /* TOHeaderImageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TOHeaderImageView.m; sourceTree = "<group>"; };
2281FE4D202E12F600D47FE2 /* Perth.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Perth.jpg; sourceTree = "<group>"; };
22AAB349202E984E00B9B39D /* OK.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = OK.jpg; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -68,7 +68,7 @@
222D3A5F202175C10015D098 /* TONavigationBarExample */ = {
isa = PBXGroup;
children = (
2281FE4D202E12F600D47FE2 /* Perth.jpg */,
22AAB349202E984E00B9B39D /* OK.jpg */,
222D3A60202175C10015D098 /* AppDelegate.h */,
222D3A61202175C10015D098 /* AppDelegate.m */,
222D3A63202175C10015D098 /* ViewController.h */,
Expand Down Expand Up @@ -152,9 +152,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2281FE4E202E12F600D47FE2 /* Perth.jpg in Resources */,
222D3A6D202175C10015D098 /* LaunchScreen.storyboard in Resources */,
222D3A6A202175C10015D098 /* Assets.xcassets in Resources */,
22AAB34A202E984E00B9B39D /* OK.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file added TONavigationBarExample/OK.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed TONavigationBarExample/Perth.jpg
Binary file not shown.
5 changes: 3 additions & 2 deletions TONavigationBarExample/SubViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ - (void)viewDidLoad {
self.title = @"SubViewController";
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;

self.headerView = [[TOHeaderImageView alloc] initWithImage:[UIImage imageNamed:@"Perth.jpg"] height:200.0f];
self.headerView.shadowHidden = NO;
self.headerView = [[TOHeaderImageView alloc] initWithImage:[UIImage imageNamed:@"OK.jpg"] height:200.0f];
self.headerView.shadowHidden = YES;
self.headerView.contentMode = UIViewContentModeScaleAspectFit; // Content mode is normally 'fill'
self.tableView.tableHeaderView = self.headerView;

self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
Expand Down
1 change: 1 addition & 0 deletions TONavigationBarExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ - (void)viewDidLoad {

self.title = @"TONavigationBar";
self.navigationController.navigationBar.prefersLargeTitles = YES;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand Down

0 comments on commit 9073fe8

Please sign in to comment.