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
- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur { | |
if (blur < 0.f || blur > 1.f) { | |
blur = 0.5f; | |
} | |
int boxSize = (int)(blur * 100); | |
boxSize = boxSize - (boxSize % 2) + 1; | |
CGImageRef img = image.CGImage; | |
vImage_Buffer inBuffer, outBuffer; |
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
- (UIImage *)blurryGPUImage:(UIImage *)image | |
withBlurLevel:(NSInteger)blur { | |
GPUImageFastBlurFilter *blurFilter = | |
[[GPUImageFastBlurFilter alloc] init]; | |
blurFilter.blurSize = blur; | |
UIImage *result = [blurFilter imageByFilteringImage:image]; | |
return result; | |
} |
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
- (UIImage *)blurryImage:(UIImage *)image | |
withBlurLevel:(CGFloat)blur { | |
CIImage *inputImage = [CIImage imageWithCGImage:image.CGImage]; | |
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" | |
keysAndValues:kCIInputImageKey, inputImage, | |
@"inputRadius", @(blur), | |
nil]; | |
CIImage *outputImage = filter.outputImage; | |
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
DVPlaylistPlayer *player = [[DVPlaylistPlayer alloc] init]; | |
[self.view addSubview:player.playerView]; | |
player.delegate = someDelegate; | |
player.dataSource = someDataSource; | |
[player playMediaAtIndex:0]; |
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 "DVViewController.h" | |
#import <CoreMotion/CoreMotion.h> | |
#define kCMDeviceMotionUpdateFrequency (1.f/30.f) | |
@interface DVViewController () | |
@property (weak, nonatomic) IBOutlet UILabel *accelerationXVal; | |
@property (weak, nonatomic) IBOutlet UILabel *accelerationYVal; | |
@property (weak, nonatomic) IBOutlet UILabel *accelerationZVal; |
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)updateMotionData { | |
//1 | |
CMAcceleration acceleration = self.motionManager.deviceMotion.userAcceleration; | |
self.accelerationXVal.text = [NSString stringWithFormat:@"%.3f", acceleration.x]; | |
self.accelerationYVal.text = [NSString stringWithFormat:@"%.3f", acceleration.y]; | |
self.accelerationZVal.text = [NSString stringWithFormat:@"%.3f", acceleration.z]; | |
// | |
//2 | |
CMAcceleration gravity = self.motionManager.deviceMotion.gravity; |
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 <UIKit/UIKit.h> | |
@interface DVParallaxView : UIView | |
@property (nonatomic, strong) UIImage *backgroundImage; | |
@property (nonatomic, strong) UIView *frontView; | |
@property (nonatomic) float parallaxDistanceFactor; | |
@property (nonatomic) float parallaxFrontFactor; | |
@property (nonatomic) CGPoint contentOffset; |
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
@interface DVParallaxView() | |
@property (nonatomic, strong) UIImageView *backgroundImageView; | |
@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
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
self.parallaxDistanceFactor = 2.f; | |
self.parallaxFrontFactor = 20.f; | |
self.backgroundColor = [UIColor clearColor]; | |
[self addSubview:self.backgroundImageView]; | |
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panHandler:)]; |
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
#pragma mark - Gesture handler | |
- (void)panHandler:(UIPanGestureRecognizer *)pan { | |
CGPoint translation = [pan translationInView:self]; | |
[self setContentOffset:CGPointMake(self.contentOffset.x + translation.x, | |
self.contentOffset.y - translation.y)]; | |
[pan setTranslation:CGPointZero inView:self]; | |
} |