This file contains 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
var origin: CGPoint? | |
var radius: CGFloat? | |
var locations: [CGFloat]? | |
var colors: [UIColor]? | |
override func drawInContext(ctx: CGContext!) { | |
super.drawInContext(ctx) | |
if let colors = self.colors { | |
if let locations = self.locations { | |
if let origin = self.origin { |
This file contains 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 SetTimeout(delay: Int64, callback: () -> Void) { | |
var delta: Int64 = delay * Int64(NSEC_PER_SEC) | |
var time = dispatch_time(DISPATCH_TIME_NOW, delta) | |
dispatch_after(time, dispatch_get_main_queue(), callback); | |
} |
This file contains 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)startProcessing | |
{ | |
// Setup CADisplayLink which will callback displayPixelBuffer: at every vsync. | |
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkCallback:)]; | |
[[self displayLink] addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; | |
[[self displayLink] setPaused:YES]; | |
// Setup AVPlayerItemVideoOutput with the required pixelbuffer attributes. | |
NSDictionary *pixBuffAttributes = @{(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)}; | |
self.playerItemOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:pixBuffAttributes]; |
This file contains 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 cell creation logic | |
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UVLVideoCell *videoCell = (UVLVideoCell *)[collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UVLVideoCell class]) forIndexPath:indexPath]; | |
NSInteger index = 1 + indexPath.item%2; | |
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:[NSString stringWithFormat:@"flak_0%i", index] withExtension:@"mp4" subdirectory:@"videos"]; | |
[videoCell loadVideoURL:sampleURL]; | |
return videoCell; |
This file contains 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 "UIAlertViewWithCallback.h" | |
static NSMutableDictionary *__UIAlertViewCachedViews; | |
@interface UIAlertViewWithCallback ()<UIAlertViewDelegate> | |
@property (nonatomic, strong) UIAlertView *alertView; | |
@property (nonatomic, copy) UIAlertViewConfirmationCallback callback; | |
@end |
This file contains 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)generateRectsForCharactersInLinks | |
{ | |
if (self.links.count == 0) | |
return; | |
CGRect textRect = [self textRectForBounds:self.bounds limitedToNumberOfLines:self.numberOfLines]; | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathAddRect(path, NULL, textRect); | |
CTFrameRef frame = CTFramesetterCreateFrame(self.framesetter, CFRangeMake(0, (CFIndex)[self.attributedText length]), path, NULL); |
This file contains 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
- (CGSize)sizeThatFits:(CGSize)size{ | |
if (!self.attributedText) | |
{ | |
return [super sizeThatFits:size]; | |
} | |
NSUInteger length = 0; | |
if ([self.text respondsToSelector:@selector(length)]) | |
{ | |
length = [self.text length]; |
This file contains 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
int64_t durationValue = [[coder decodeObjectForKey:@"durationTimeValue"] intValue]; | |
int32_t durationScale = [[coder decodeObjectForKey:@"durationTimeScale"] intValue]; | |
int64_t startValue = [[coder decodeObjectForKey:@"startTimeValue"] intValue]; | |
int32_t startScale = [[coder decodeObjectForKey:@"startTimeScale"] intValue]; | |
CMTime duration; | |
duration.value = durationValue; | |
duration.timescale = durationScale; | |