Permalink
Browse files

MINOR: Original UIToolbar style

  • Loading branch information...
1 parent fedbc3c commit 1be8bb85c94b6761d922727c58ef3edda65ddf31 @weissi committed May 12, 2012
@@ -38,6 +38,9 @@
DAB8C67E155E8F6A00340CB7 /* FRLayeredNavigationItem+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB8C67C155E8F6900340CB7 /* FRLayeredNavigationItem+Protected.h */; };
DAB8C686155E93E700340CB7 /* FRLayerController+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB8C684155E93E700340CB7 /* FRLayerController+Protected.h */; };
DAB8C68C155E9DEE00340CB7 /* back.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB8C68B155E9DEE00340CB7 /* back.png */; };
+ DAB8C6C1155EBF3900340CB7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB8C6BF155EBD3100340CB7 /* QuartzCore.framework */; };
+ DAB8C6C2155EBF4400340CB7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4FAD0415591BD500D85A7E /* UIKit.framework */; };
+ DAB8C6C3155EBF5800340CB7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB8C6BF155EBD3100340CB7 /* QuartzCore.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -88,13 +91,17 @@
DAB8C67C155E8F6900340CB7 /* FRLayeredNavigationItem+Protected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FRLayeredNavigationItem+Protected.h"; sourceTree = "<group>"; };
DAB8C684155E93E700340CB7 /* FRLayerController+Protected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FRLayerController+Protected.h"; sourceTree = "<group>"; };
DAB8C68B155E9DEE00340CB7 /* back.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = back.png; sourceTree = "<group>"; };
+ DAB8C6BC155EBD1200340CB7 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; };
+ DAB8C6BF155EBD3100340CB7 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
DA4FACC315591AB300D85A7E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ DAB8C6C2155EBF4400340CB7 /* UIKit.framework in Frameworks */,
+ DAB8C6C1155EBF3900340CB7 /* QuartzCore.framework in Frameworks */,
DA4FACCA15591AB300D85A7E /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -103,6 +110,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ DAB8C6C3155EBF5800340CB7 /* QuartzCore.framework in Frameworks */,
DA5B059B155923D000C93809 /* libFRLayeredNavigationController.a in Frameworks */,
DA4FAD0515591BD500D85A7E /* UIKit.framework in Frameworks */,
DA4FAD0615591BD500D85A7E /* Foundation.framework in Frameworks */,
@@ -116,6 +124,8 @@
DA4FACBB15591AB300D85A7E = {
isa = PBXGroup;
children = (
+ DAB8C6BF155EBD3100340CB7 /* QuartzCore.framework */,
+ DAB8C6BC155EBD1200340CB7 /* CoreImage.framework */,
DA4FAD2715591C6E00D85A7E /* AUTHORS */,
DA4FAD2815591C6E00D85A7E /* COPYING */,
DA4FAD2915591C6E00D85A7E /* COPYING.LESSER */,
@@ -20,7 +20,6 @@
#import <UIKit/UIKit.h>
@interface FRLayerChromeView : UIView {
- CGGradientRef _savedGradient;
UIToolbar *_toolbar;
UIBarButtonItem *_leftBarButtonItem;
UIBarButtonItem *_rightBarButtonItem;
@@ -18,6 +18,8 @@
*/
#import "FRLayerChromeView.h"
+#import <QuartzCore/QuartzCore.h>
+
@interface FRLayerChromeView ()
@@ -29,10 +31,10 @@ -(id)initWithFrame:(CGRect)frame titleView:(UIView *)titleView title:(NSString *
{
self = [super initWithFrame:frame];
if (self) {
- _savedGradient = nil;
- self.backgroundColor = [UIColor clearColor];
-
_toolbar = [[UIToolbar alloc] initWithFrame:CGRectZero];
+ _toolbar.clipsToBounds = YES;
+ self.clipsToBounds = YES;
+
[self addSubview:_toolbar];
if (titleView == nil) {
@@ -58,11 +60,6 @@ -(id)initWithFrame:(CGRect)frame titleView:(UIView *)titleView title:(NSString *
return self;
}
-- (void)dealloc {
- CGGradientRelease(self->_savedGradient);
- self->_savedGradient = NULL;
-}
-
- (void)manageToolbar
{
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
@@ -97,11 +94,12 @@ - (void)layoutSubviews {
CGFloat barButtonItemsSpace = (self.leftBarButtonItem!=nil?44:0) + (self.rightBarButtonItem!=nil?44:0);
- self.toolbar.frame = CGRectMake(5, 0, self.bounds.size.width-10, self.bounds.size.height);
+ //self.toolbar.frame = CGRectMake(10, 0, self.bounds.size.width-20, self.bounds.size.height);
+ self.toolbar.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
- CGRect headerMiddleFrame = CGRectMake(5 + (barButtonItemsSpace/2),
+ CGRect headerMiddleFrame = CGRectMake(10 + (barButtonItemsSpace/2),
0,
- self.bounds.size.width-10-barButtonItemsSpace,
+ self.bounds.size.width-20-barButtonItemsSpace,
self.bounds.size.height);
CGSize titleFittingSize = [self.titleView sizeThatFits:headerMiddleFrame.size];
@@ -113,45 +111,20 @@ - (void)layoutSubviews {
MIN(titleFittingSize.height, headerMiddleFrame.size.height));
self.titleView.frame = titleFrame;
-}
-
-- (CGGradientRef)gradient {
- if (NULL == _savedGradient) {
- CGFloat colors[12] = {
- 244.0/255.0, 245.0/255.0, 247.0/255.0, 1.0,
- 223.0/255.0, 225.0/255.0, 230.0/255.0, 1.0,
- 167.0/244.0, 171.0/255.0, 184.0/255.0, 1.0,
- };
- CGFloat locations[3] = { 0.05f, 0.45f, 0.95f };
-
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-
- _savedGradient = CGGradientCreateWithColorComponents(colorSpace,
- colors,
- locations,
- 3);
-
- CGColorSpaceRelease(colorSpace);
- }
-
- return _savedGradient;
-}
-
-- (void)drawRect:(CGRect)rect
-{
- CGContextRef ctx = UIGraphicsGetCurrentContext();
- UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
- byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
- [path addClip];
- CGPoint start = CGPointMake(CGRectGetMidX(self.bounds), 0);
- CGPoint end = CGPointMake(CGRectGetMidX(self.bounds),
- CGRectGetMaxY(self.bounds));
+ // Create the path (with only the top-left corner rounded)
+ UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
+ byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
+ cornerRadii:CGSizeMake(10.0, 10.0)];
- CGGradientRef gradient = [self gradient];
+ // Create the shape layer and set its path
+ CAShapeLayer *maskLayer = [CAShapeLayer layer];
+ maskLayer.frame = self.bounds;
+ maskLayer.path = maskPath.CGPath;
- CGContextDrawLinearGradient(ctx, gradient, start, end, 0);
+ // Set the newly created shape layer as the mask for the image view's layer
+ self.layer.mask = maskLayer;
}
@synthesize leftBarButtonItem = _leftBarButtonItem;
@@ -24,6 +24,8 @@
#import <QuartzCore/QuartzCore.h>
+#define FRLayerChromeHeight ((CGFloat)44)
+
@interface FRLayerController ()
@property (nonatomic, readwrite, strong) UIViewController *contentViewController;
@@ -78,22 +80,22 @@ - (void)doViewLayout {
CGRect chromeFrame = CGRectMake(0,
0,
self.view.bounds.size.width,
- 44);
+ FRLayerChromeHeight);
CGRect borderFrame = CGRectMake(0,
- 44,
+ FRLayerChromeHeight,
self.view.bounds.size.width,
- self.view.bounds.size.height-44);
+ self.view.bounds.size.height-FRLayerChromeHeight);
contentFrame = CGRectMake(1,
- 45,
+ FRLayerChromeHeight + 1,
self.view.bounds.size.width-2,
- self.view.bounds.size.height-46);
+ self.view.bounds.size.height-FRLayerChromeHeight-2);
self.borderView.frame = borderFrame;
self.chromeView.frame = chromeFrame;
} else {
contentFrame = CGRectMake(0,
- 0,
- self.view.bounds.size.width,
- self.view.bounds.size.height);
+ 0,
+ self.view.bounds.size.width,
+ self.view.bounds.size.height);
}
@@ -1,10 +1,21 @@
-//
-// FRLayeredNavigation.h
-// FRLayeredNavigationController
-//
-// Created by Johannes Weiß on 5/8/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/* This file is part of FRLayeredNavigationController.
+ *
+ * FRLayeredNavigationController is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * FRLayeredNavigationController is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with FRLayeredNavigationController. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * Copyright (c) 2012, Johannes Weiß <weiss@tux4u.de> for factis research GmbH.
+ */
#import "FRLayeredNavigationController.h"
#import "FRLayeredNavigationItem.h"

0 comments on commit 1be8bb8

Please sign in to comment.