- (UIViewController *)viewController {
for (UIView *nextView = self; nextView; nextView = nextView.superview) {
UIResponder *nextResponder = [nextView nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return 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
# inhibit_all_warnings! | |
# If you enable inhibit_all_warnings, we will not see warnings from our developer Pods. | |
# inhibit_all_warnings Оключает отображение warning во всех подключенных Pods. И мы не видим предупреждение в наших developer Pods | |
# Solution: Disable warning only for third party Pods | |
# Решение: Отключить показ warning только для сторонних подов | |
# Solution: for custom pods https://stackoverflow.com/a/44530816 | |
# Решение: для выборочного отключения https://stackoverflow.com/a/44530816 |
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 UIImage (Draw) | |
//画一个直角矩形图片 | |
+ (UIImage *)drawRectImageWithColor:(UIColor *)color size:(CGSize)size { | |
CGRect rect = CGRectMake(0, 0, size.width, size.height); | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(context, [color CGColor]); |
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
require 'cocoapods' | |
def integrate_umbrella_header(installer) | |
# 把"xxx-Bridging-Header.h"桥接头文件插入到"xxx-umbrella.h"第一个import语句之前,解决引入Swift之后头文件引用的报错问题 | |
installer.pod_targets.each do |target| | |
next unless target.uses_swift? and File.exist?(target.umbrella_header_path) | |
sandbox = File.expand_path(target.pod_target_srcroot.to_s.gsub(/\$\{PODS_ROOT\}/, target.sandbox.root.to_s)) | |
bridging_header_file_name = "#{target.name}-Bridging-Header.h" | |
bridging_header_files = Dir["#{sandbox}/**/#{bridging_header_file_name}"] | |
if bridging_header_files.empty? |
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
CGRect rect = AVMakeRectWithAspectRatioInsideRect(self.imageView.image.size, self.imageView.frame); | |
if (!(isnan(rect.origin.x) || isnan(rect.origin.y) || | |
isnan(rect.size.width) || isnan(rect.size.height))) { | |
self.imageView.frame = rect; | |
} |
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
let data: Data? = try? Data(contentsOf: Bundle.main.url(forResource: "exposure_tab_gray_arrow_right@2x", withExtension: "png")!) | |
internal struct ImageHeaderData { | |
static var PNG: [UInt8] = [0x89] | |
static var JPEG: [UInt8] = [0xFF] | |
static var GIF: [UInt8] = [0x47] | |
static var BMP: [UInt8] = [0x42] | |
static var TIFF_01: [UInt8] = [0x49] | |
static var TIFF_02: [UInt8] = [0x4D] | |
} |
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
BUILD_CAUSE_JSON=$(curl --silent ${BUILD_URL}/api/json | tr "{}" "\n" | grep "Started by") | |
BUILD_USER_ID=$(echo $BUILD_CAUSE_JSON | tr "," "\n" | grep "userId" | awk -F\" '{print $4}') | |
BUILD_USER_NAME=$(echo $BUILD_CAUSE_JSON | tr "," "\n" | grep "userName" | awk -F\" '{print $4}') |
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)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
UIGestureRecognizer *popGesture = self.navigationController.interactivePopGestureRecognizer; | |
if ([popGesture isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) { | |
((UIScreenEdgePanGestureRecognizer *)popGesture).edges = UIRectEdgeNone; | |
} | |
} |
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
func measure(block: () -> Void) -> Double { | |
let start = DispatchTime.now() | |
block() | |
let end = DispatchTime.now() | |
let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds // <<<<< Difference in nano seconds (UInt64) | |
let timeInterval = Double(nanoTime) / 1_000_000_000 | |
return timeInterval | |
} |
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
+(NSData*) dataWithInputStream:(NSInputStream*) stream { | |
NSMutableData * data = [NSMutableData data]; | |
[stream open]; | |
NSInteger result; | |
uint8_t buffer[1024]; // BUFFER_LEN can be any positive integer | |
while((result = [stream read:buffer maxLength:1024]) != 0) { | |
if(result > 0) { | |
// buffer contains result bytes of data to be handled |
NewerOlder