Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
UINavigationBar+AwesomeCategories
UINavigationController+FDFullscreenPopGesture
UITableView+FDTemplateLayoutCell
  • Loading branch information
Jakey authored and Jakey committed Aug 18, 2015
1 parent 5c3b926 commit 75e13e5
Show file tree
Hide file tree
Showing 14 changed files with 866 additions and 165 deletions.
4 changes: 2 additions & 2 deletions Categories/UIKit/UINavigationBar/UINavigationBar+Awesome.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@interface UINavigationBar (Awesome)
- (void)lt_setBackgroundColor:(UIColor *)backgroundColor;
- (void)lt_setContentAlpha:(CGFloat)alpha;
- (void)lt_setElementsAlpha:(CGFloat)alpha;
- (void)lt_setTranslationY:(CGFloat)translationY;
- (void)lt_reset;
@end
@end
50 changes: 13 additions & 37 deletions Categories/UIKit/UINavigationBar/UINavigationBar+Awesome.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

@implementation UINavigationBar (Awesome)
static char overlayKey;
static char emptyImageKey;

- (UIView *)overlay
{
Expand All @@ -23,21 +22,11 @@ - (void)setOverlay:(UIView *)overlay
objc_setAssociatedObject(self, &overlayKey, overlay, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (UIImage *)emptyImage
{
return objc_getAssociatedObject(self, &emptyImageKey);
}

- (void)setEmptyImage:(UIImage *)image
{
objc_setAssociatedObject(self, &emptyImageKey, image, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)lt_setBackgroundColor:(UIColor *)backgroundColor
{
if (!self.overlay) {
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, 64)];
self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, CGRectGetHeight(self.bounds) + 20)];
self.overlay.userInteractionEnabled = NO;
self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
[self insertSubview:self.overlay atIndex:0];
Expand All @@ -50,38 +39,25 @@ - (void)lt_setTranslationY:(CGFloat)translationY
self.transform = CGAffineTransformMakeTranslation(0, translationY);
}

- (void)lt_setContentAlpha:(CGFloat)alpha
{
if (!self.overlay) {
[self lt_setBackgroundColor:self.barTintColor];
}
[self setAlpha:alpha forSubviewsOfView:self];
if (alpha == 1) {
if (!self.emptyImage) {
self.emptyImage = [UIImage new];
}
self.backIndicatorImage = self.emptyImage;
}
}

- (void)setAlpha:(CGFloat)alpha forSubviewsOfView:(UIView *)view
- (void)lt_setElementsAlpha:(CGFloat)alpha
{
for (UIView *subview in view.subviews) {
if (subview == self.overlay) {
continue;
}
subview.alpha = alpha;
[self setAlpha:alpha forSubviewsOfView:subview];
}
[[self valueForKey:@"_leftViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
view.alpha = alpha;
}];

[[self valueForKey:@"_rightViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
view.alpha = alpha;
}];

UIView *titleView = [self valueForKey:@"_titleView"];
titleView.alpha = alpha;
}

- (void)lt_reset
{
[self setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self setShadowImage:nil];

[self.overlay removeFromSuperview];
self.overlay = nil;
}

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,41 @@
// https://github.com/forkingdog/FDFullscreenPopGesture
#import <UIKit/UIKit.h>

/// "UINavigation+FDFullscreenPopGesture" extends UINavigationController's swipe-
/// to-pop behavior in iOS 7+ by supporting fullscreen pan gesture. Instead of
/// screen edge, you can now swipe from any place on the screen and the onboard
/// interactive pop transition works seamlessly.
///
/// Adding the implementation file of this category to your target will
/// automatically patch UINavigationController with this feature.
@interface UINavigationController (FDFullscreenPopGesture)

@property (nonatomic, strong, readonly) UIPanGestureRecognizer *fd_popGestureRecognizer;
/// The gesture recognizer that actually handles interactive pop.
@property (nonatomic, strong, readonly) UIPanGestureRecognizer *fd_fullscreenPopGestureRecognizer;

/// A view controller is able to control navigation bar's appearance by itself,
/// rather than a global way, checking "fd_prefersNavigationBarHidden" property.
/// Default to YES, disable it if you don't want so.
@property (nonatomic, assign) BOOL fd_viewControllerBasedNavigationBarAppearanceEnabled;

@end

/// Allows any view controller to disable interactive pop gesture, which might
/// be necessary when the view controller itself handles pan gesture in some
/// cases.
@interface UIViewController (FDFullscreenPopGesture)

/// Whether the interactive pop gesture is disabled when contained in a navigation
/// stack.
@property (nonatomic, assign) BOOL fd_interactivePopDisabled;

/// Indicate this view controller prefers its navigation bar hidden or not,
/// checked when view controller based navigation bar's appearance is enabled.
/// Default to NO, bars are more likely to show.
@property (nonatomic, assign) BOOL fd_prefersNavigationBarHidden;

/// Max allowed initial distance to left edge when you begin the interactive pop
/// gesture. 0 by default, which means it will ignore this limit.
@property (nonatomic, assign) CGFloat fd_interactivePopMaxAllowedInitialDistanceToLeftEdge;

@end
Loading

0 comments on commit 75e13e5

Please sign in to comment.