This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIScrollView+zoomToCenterWithScale.h | |
| // locationme | |
| // | |
| // Created by 金燕赖 on 14-6-22. | |
| // Copyright (c) 2014年 ljy. All rights reserved. | |
| // | |
| #import <UIKit/UIKit.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //CGDisplayIOServicePort is depreciated in OS 10.9 – so you have to use IOServiceGetMatchingServices to get the service parameter for IODisplaySetFloatParameter. | |
| - (void) setBrightnessTo: (float) level | |
| { | |
| io_iterator_t iterator; | |
| kern_return_t result = IOServiceGetMatchingServices(kIOMasterPortDefault, | |
| IOServiceMatching("IODisplayConnect"), | |
| &iterator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| expression = [NSExpression expressionForFunction:@"distanceToLocation:fromLocation:" | |
| arguments:@[ | |
| [NSExpression expressionForConstantValue:to ], | |
| [NSExpression expressionForConstantValue:from ] | |
| ] | |
| ]; | |
| result = (NSNumber *)[expression expressionValueWithObject:nil context:nil]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| predicate = [NSPredicate predicateWithFormat:@"distanceToLocation:fromLocation:(%@, %@) =< %@", | |
| toLocation, | |
| fromLocation, | |
| expectedDistance | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation UIView (PSPDFKitAdditions) | |
| - (UIViewController *)pspdf_closestViewController { | |
| UIResponder *responder = self; | |
| while ((responder = [responder nextResponder])) { | |
| if ([responder isKindOfClass:UIViewController.class]) break; | |
| } | |
| return (UIViewController *)responder; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PSPDF_EXTERN BOOL PSPDFIsBlock(id _Nullable block) { | |
| static Class blockClass; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| blockClass = [^{} class]; | |
| while ([blockClass superclass] != NSObject.class) { | |
| blockClass = [blockClass superclass]; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The trick is to copy the DeviceSupport folder from the beta to the stable version. | |
| cp -r /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.0\ \(14A5261u\) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ | |
| // Then restart Xcode. You might need to do that for every beta of iOS 10/Xcode 8. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <UIKit/UIKit.h> | |
| @interface UIColor (isLight) | |
| - (CGFloat)lightness; | |
| - (CGFloat)perceivedLightness; | |
| - (CGFloat)perceivedLightnessW3C; | |
| - (BOOL)isLight; | |
| - (BOOL)isPerceivedLightW3C; | |
| - (BOOL)isPerceivedLight; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)presentOverViewController:(ASViewController *)viewController | |
| { | |
| if ([[UIDevice currentDevice].systemVersion integerValue] >= 8) { | |
| //For iOS 8 | |
| viewController.providesPresentationContextTransitionStyle = YES; | |
| viewController.definesPresentationContext = YES; | |
| viewController.modalPresentationStyle = UIModalPresentationOverCurrentContext; | |
| [viewController presentViewController:self animated:NO completion:nil]; | |
| } | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { | |
| [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; | |
| //The device has already rotated, that's why this method is being called. | |
| UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation]; | |
| //fixes orientation mismatch (between UIDeviceOrientation and UIInterfaceOrientation) | |
| UIInterfaceOrientation toOrientation; | |
| switch (deviceOrientation) { | |
| case UIDeviceOrientationUnknown: | |
| toOrientation = UIInterfaceOrientationUnknown; |