UIBlurEffect *blur =[UIBlurEffecteffectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:blur];
blurView.frame = self.hudView.bounds;
[self.view addSubview:blurView];
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)scrollViewDoubleTapped:(UITapGestureRecognizer*)recognizer { | |
// 1 | |
CGPoint pointInView = [recognizer locationInView:self.imageView]; | |
// 2 | |
CGFloat newZoomScale = self.scrollView.zoomScale * 1.5f; | |
newZoomScale = MIN(newZoomScale, self.scrollView.maximumZoomScale); | |
// 3 | |
CGSize scrollViewSize = self.scrollView.bounds.size; |
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
// Can also be placed within scrollviews layoutSubviews | |
- (void)centerScrollViewContents { | |
CGSize boundsSize = self.scrollView.bounds.size; | |
CGRect contentsFrame = self.imageView.frame; | |
if (contentsFrame.size.width < boundsSize.width) { | |
contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2.0f; | |
} else { | |
contentsFrame.origin.x = 0.0f; |
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)scrollViewWillBeginDragging:(UIScrollView *)scrollView { | |
CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview]; | |
if(translation.y > 0) | |
{ | |
NSLog(@"dragging downwards!"); | |
} else | |
{ | |
NSLog(@"dragging up!"); | |
} |
UIVisualEffectView *vibrantView = [[UIVisualEffectView alloc] initWithEffect:[UIVibrancyEffect effectForBlurEffect:blur]]; vibrantView.frame = blurView.bounds;
UILabel *label = [[UILabel alloc] init];
[label setFont:[UIFont fontWithName:@"HelveticaNeue" size:33]]; label.frame = CGRectMake(8, 30, 400, 500);
label.numberOfLines = 0;
label.text = @"THIS IS VIBRANT TEXT!";
// add vibrantView to first blurView
[vibrantView.contentView addSubview:label];
[blurView.contentView addSubview:vibrantView];
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 XCPlayground | |
import AudioKit | |
let osc = AKWhiteNoise() | |
let filter = AKLowPassFilter(osc, cutoffFrequency: 200, resonance: 3) | |
osc.start() | |
let verb = AKReverb(filter) | |
verb.dryWetMix = 0.5 |
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
hello() { name in | |
... some code ... | |
anotherMethod { anotherThing in | |
.. I'm nested in two closures | |
} | |
} |
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 unwrap<T:Any>(dictionary:[String : AnyObject], key:String, defaultValue:T) -> T { | |
let value = dictionary[key] as? T ?? defaultValue | |
return value as T | |
} | |
// Can be curried inside a init?(json:NSDictionary) function | |
let stringAtKey:(String) -> String = { key in | |
return unwrap(dictionary , key:key, defaultValue:"") |
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
+ (BOOL)resolveInstanceMethod:(SEL)aSEL { | |
NSString *classname = NSStringFromClass([self class]); | |
NSString *selectorString = [NSString stringWithFormat:@"insaneInstance%@",classname]; | |
SEL ourSelector = NSSelectorFromString(selectorString); | |
if (aSEL == ourSelector) { | |
class_addMethod([self class], aSEL, (IMP)insaneInstanceMethod, "v@:"); | |
return YES; | |
} | |
return [super resolveInstanceMethod:aSEL]; | |
} |
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
+ (BOOL)resolveClassMethod:(SEL)name { | |
NSString *classname = NSStringFromClass([self class]); | |
NSString *selectorString = [NSString stringWithFormat:@"crazyClass%@",classname]; | |
NSLog(@"string is %@", selectorString); | |
SEL ourSelector = NSSelectorFromString(selectorString); | |
if (name == ourSelector) { | |
// adding class method to meta-class | |
Class ourClass = object_getClass(NSClassFromString(classname)); | |
class_addMethod(ourClass, ourSelector, (IMP)crazyClassMethod, "@v:@"); |