Skip to content

Commit

Permalink
UIButton+TouchAreaInsets
Browse files Browse the repository at this point in the history
UINavigationController+JZExtension
UINavigationItem+Margin
UIViewController+BlockSegue
  • Loading branch information
Jakey authored and Jakey committed Jul 3, 2015
1 parent e4952b2 commit 313d1de
Show file tree
Hide file tree
Showing 10 changed files with 919 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Categories/UIKit/UIButton/UIButton+TouchAreaInsets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Suyeol Jeon (xoul.kr)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//https://github.com/devxoul/UIButton-TouchAreaInsets

#import <UIKit/UIKit.h>

@interface UIButton (JLUtils)

@property (nonatomic, assign) UIEdgeInsets touchAreaInsets;

@end
52 changes: 52 additions & 0 deletions Categories/UIKit/UIButton/UIButton+TouchAreaInsets.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Suyeol Jeon (xoul.kr)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

#import <objc/runtime.h>
#import "UIButton+TouchAreaInsets.h"

@implementation UIButton (JLUtils)

- (UIEdgeInsets)touchAreaInsets
{
return [objc_getAssociatedObject(self, @selector(touchAreaInsets)) UIEdgeInsetsValue];
}

- (void)setTouchAreaInsets:(UIEdgeInsets)touchAreaInsets
{
NSValue *value = [NSValue valueWithUIEdgeInsets:touchAreaInsets];
objc_setAssociatedObject(self, @selector(touchAreaInsets), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
UIEdgeInsets touchAreaInsets = self.touchAreaInsets;
CGRect bounds = self.bounds;
bounds = CGRectMake(bounds.origin.x - touchAreaInsets.left,
bounds.origin.y - touchAreaInsets.top,
bounds.size.width + touchAreaInsets.left + touchAreaInsets.right,
bounds.size.height + touchAreaInsets.top + touchAreaInsets.bottom);
return CGRectContainsPoint(bounds, point);
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2016 JazysYu ( https://github.com/JazysYu )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//https://github.com/JazysYu/JZNavigationExtension
#import <UIKit/UIKit.h>

/// The "UINavigationController+JZExtension" category integrates some convenient functions and open some hide property
/// for UINavigationController, such as gives your UINavigationController a fullscreen interactivePopGestureRecognizer,
/// all you need is enable/disable "fullScreenInteractivePopGestureRecognizer" property for each ViewController.
/// If you have some ViewController which doesn't wants a navigation bar, you can set the "hidesNavigationBarWhenPushed"
/// property to YES.
/// You can also adjust your navigationBar or toolbar's background alpha.
@interface UINavigationController (JZExtension)

@property (nonatomic, assign) BOOL fullScreenInteractivePopGestureRecognizer NS_AVAILABLE_IOS(7_0); // If YES, then you can have a fullscreen
/// gesture recognizer responsible for popping the top view controller off the navigation stack, and the property is still
/// "interactivePopGestureRecognizer", see more for "UINavigationController.h", Default is NO.
@property (nonatomic, assign) CGFloat navigationBarBackgroundAlpha NS_AVAILABLE_IOS(7_0); // navigationBar's background alpha, when 0 your
/// navigationBar will be invisable, default is 1. Animatable
@property (nonatomic, assign) CGFloat toolbarBackgroundAlpha NS_AVAILABLE_IOS(7_0); // Current navigationController's toolbar background alpha,
/// make sure the toolbarHidden property is NO, default is 1. Animatable
@property (nonatomic, readonly, strong) UIViewController *interactivePopedViewController NS_AVAILABLE_IOS(7_0); // The view controller that is being popped
/// when the interactive pop gesture recognizer's UIGestureRecognizerState is UIGestureRecognizerStateChanged.
/// This category helps to change navigationBar or toolBar to any size, you may also change its frame.size by yourself.
- (void)setNavigationBarSize:(CGSize)navigationBarSize;
- (void)setToolbarSize:(CGSize)toolbarSize;

- (UIViewController *)previousViewControllerForViewController:(UIViewController *)viewController; // Return the gives
/// view controller's previous view controller in the navigation stack.

/// Called at end of animation of push/pop or immediately if not animated.
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
- (UIViewController *)popViewControllerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;

@end

@interface UIViewController (JZExtension)

@property(nonatomic, assign) BOOL hidesNavigationBarWhenPushed; // If YES, then when this view controller is pushed into a controller hierarchy with a navigation bar, the navigation bar will slide out. Default is NO.

@property (nonatomic, assign, getter=isNavigationBarBackgroundHidden) BOOL navigationBarBackgroundHidden;
- (void)setNavigationBarBackgroundHidden:(BOOL)navigationBarBackgroundHidden animated:(BOOL)animated NS_AVAILABLE_IOS(8_0); // Hide or show the navigation bar background. If animated, it will transition vertically using UINavigationControllerHideShowBarDuration.

@end
Loading

0 comments on commit 313d1de

Please sign in to comment.