Skip to content

Instantly share code, notes, and snippets.

@leilee
leilee / OUPVideoPlayerView.h
Created September 25, 2017 08:20
VideoPlayerView
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@interface OUPVideoPlayerView : UIView
@property (nonatomic) BOOL showsPlayhead;
- (void)playItem:(AVPlayerItem*)item repeated:(BOOL)repeated;
- (void)replay;
- (void)pause;
@leilee
leilee / OUPZoomImageView.h
Last active December 28, 2022 08:12
View to expand & zoom the photo. Inspired by https://github.com/muukii/ZoomImageView
#import <UIKit/UIKit.h>
@interface OUPZoomImageView : UIScrollView
@property (nonatomic) UIImage* image;
@end
@leilee
leilee / UIView+UPGradientBorder.h
Created September 21, 2017 09:31
Add gradient border to UIView
#import <UIKit/UIKit.h>
@interface UIView (UPGradientBorder)
- (void)up_setHorizontalGradientBorderWithColors:(NSArray<UIColor*>*)colors borderWidth:(CGFloat)borderWidth;
- (void)up_setVerticalGradientBorderWithColors:(NSArray<UIColor*>*)colors borderWidth:(CGFloat)borderWidth;
- (void)up_setGradientBorderWithColors:(NSArray<UIColor*>*)colors borderWidth:(CGFloat)borderWidth startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
- (void)up_removeGradientBorder;
@end
//
// PSPDFFastEnumeration.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
@protocol PSPDFFastEnumeration <NSFastEnumeration>
@leilee
leilee / UIView+GradientBorder.swift
Last active March 29, 2024 12:05
Add gradient border to UIView
public extension UIView {
private static let kLayerNameGradientBorder = "GradientBorderLayer"
public func setGradientBorder(
width: CGFloat,
colors: [UIColor],
startPoint: CGPoint = CGPoint(x: 0.5, y: 0),
endPoint: CGPoint = CGPoint(x: 0.5, y: 1)
) {
+ (id)sharedInstance
{
static __weak ASingletonClass *instance;
ASingletonClass *strongInstance = instance;
@synchronized(self) {
if (strongInstance == nil) {
strongInstance = [[[self class] alloc] init];
instance = strongInstance;
}
}
@leilee
leilee / Example.m
Last active September 15, 2017 05:51
OBJC_DYNAMIC_CAST
auto a = [NSMutableArray array];
if (auto array = OBJC_DYNAMIC_CAST(a, NSArray))
{
// blablabla
}
@leilee
leilee / gist:798839857cc79536805e423471d694a3
Created July 12, 2017 08:27 — forked from steipete/gist:6133152
Create a hash from a CGRect
NSUInteger PSPDFHashFromCGRect(CGRect rect) {
return (*(NSUInteger *)&rect.origin.x << 10 ^ *(NSUInteger *)&rect.origin.y) + (*(NSUInteger *)&rect.size.width << 10 ^ *(NSUInteger *)&rect.size.height);
}
@leilee
leilee / CCacheMacNinja.md
Created July 6, 2017 08:45 — forked from jjgod/CCacheMacNinja.md
Using ccache for Mac builds

Introduction

ccache is a compiler cache. It speeds up recompilation of C/C++ code by caching previous compilations and detecting when the same compilation is being done again. This often results in a significant speedup in common compilations, especially when switching between branches. This page is about using ccache on Mac with clang and ninja build system. If you want to use Xcode, please refer to the old CCacheMac page.

In order to use ccache with clang, you need to use the current git HEAD, since the most recent version (3.1.9) doesn't contain the patch needed for using chromium style plugin.

Installation

To install ccache with [homebrew](http://mxcl.

@leilee
leilee / Cycript Printing view hierarchy.sh
Created June 27, 2017 08:53
Cycript Printing view hierarchy
cy# UIApp.keyWindow.recursiveDescription().toString()