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
Basic QuartzCore Framework Animations | |
//shrinking - scaling | |
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; | |
shrink.toValue = [NSNumber numberWithDouble:0.9]; | |
shrink.duration = 0.5; | |
shrink.delegate = self; | |
[[targetView layer] addAnimation:shrink forKey:@"shrink"]; | |
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
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section | |
{ | |
UITableViewHeaderFooterView *headerView = [[UITableViewHeaderFooterView alloc] init]; | |
[headerView.contentView addSubview:self.someView]; | |
return headerView; | |
} | |
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { | |
return CGRectGetHeight(self.someView.frame); //play around with this value |
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
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | |
[rotationAnimation setRepeatCount:MAXFLOAT]; | |
[rotationAnimation setDuration:0.2]; | |
[rotationAnimation setAutoreverses:YES]; | |
[rotationAnimation setFromValue:@(M_PI / 25.0)]; | |
[rotationAnimation setToValue:@(-M_PI/ 25.0)]; | |
[someview.layer addAnimation:rotationAnimation forKey:@"wiggle"]; |
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
[[UINavigationBar appearance] setTintColor:[UIColor grayColor]]; | |
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault]; // Takes out title | |
UIImage *backButtonImage = [UIImage imageNamed:@"BackArrowDark.png"]; | |
if ([UINavigationBar instancesRespondToSelector:@selector(setBackIndicatorImage:)]) { | |
[[UINavigationBar appearance] setBackIndicatorImage:backButtonImage]; | |
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backButtonImage]; | |
} else { | |
int imageSize = 21; // REPLACE WITH YOUR IMAGE WIDTH |
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 frame = [self.view frame]; | |
CGPoint topLeft = CGPointMake(CGRectGetMinX(frame), CGRectGetMinY(frame)); | |
CGPoint topRight = CGPointMake(CGRectGetMaxX(frame), CGRectGetMinY(frame)); | |
CGPoint bottomLeft = CGPointMake(CGRectGetMinX(frame), CGRectGetMaxY(frame)); | |
CGPoint bottomRight = CGPointMake(CGRectGetMaxX(frame), CGRectGetMaxY(frame)); | |
//If you need those coordinates in a particular view, the first line should be something like | |
CGRect frame = [self.view convertRect:[self.view bounds] toView:someOtherView]; |
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
@property (strong, nonatomic) AVCaptureDevice* device; | |
@property (strong, nonatomic) AVCaptureDeviceInput* input; | |
@property (strong, nonatomic) AVCaptureMetadataOutput* output; | |
@property (strong, nonatomic) AVCaptureSession* session; | |
@property (strong, nonatomic) AVCaptureVideoPreviewLayer* preview; | |
@property (strong, nonatomic) AVCaptureStillImageOutput* imgIO; | |
self.session = [[AVCaptureSession alloc] init]; | |
self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
NSError *error = 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
- (UIImage*)imageWithBorderFromImage:(UIImage*)source; | |
{ | |
CGSize size = [source size]; | |
UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width, size.height+20), NO, 0.0); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[source drawInRect:CGRectMake(0, 20, size.width, 44)]; | |
CGContextFillRect(context, CGRectMake(0, 0, size.width, 20)); |
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)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate(BOOL)decelerate { | |
if (decelerate == NO) { | |
[self autoAdjustScrollToTop]; | |
} | |
} | |
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | |
[self autoAdjustScrollToTop]; | |
} | |
- (void)autoAdjustScrollToTop { | |
// compare the top two visible rows to the current content offset |
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
//Detect when tableview is updating | |
[CATransaction begin]; | |
[CATransaction setCompletionBlock:^{ | |
// animation has finished | |
}]; | |
[tableView beginUpdates]; | |
// do some work |
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
//http://www.tutorialspoint.com/cprogramming/c_preprocessors.htm | |
#define Substitutes a preprocessor macro | |
#include Inserts a particular header from another file | |
#undef Undefines a preprocessor macro | |
#ifdef Returns true if this macro is defined | |
#ifndef Returns true if this macro is not defined | |
#if Tests if a compile time condition is true | |
#else The alternative for #if | |
#elif #else an #if in one statement |