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)drawRect:(CGRect)rect | |
{ | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
UIColor *outerShadowColor = [UIColor.blackColor colorWithAlphaComponent:1.0]; | |
UIColor *innerShadowColor = [UIColor.blackColor colorWithAlphaComponent:0.6]; | |
// Calc the shadow attribs based on the delta rotation | |
CMQuaternion newRotation = _motionManager.deviceMotion.attitude.quaternion; | |
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
static float _MapRange(float inVal, float inMin, float inMax, float outMin, float outMax) { | |
return ( (inVal-inMin) / (inMax-inMin) * (outMax-outMin) + outMin ); | |
} | |
static float _MapBilinearRange(float inVal, float inMin, float inMed, float inMax, float outMin, float outMed, float outMax) | |
{ | |
if (inVal < inMed) | |
return ( (inVal-inMin) / (inMed-inMin) * (outMed-outMin) + outMin ); | |
else | |
return ( (inVal-inMed) / (inMax-inMed) * (outMax-outMed) + outMed ); | |
} |
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
CATransition *animation = [CATransition animation]; | |
animation.delegate = self; | |
animation.startProgress = 0.0; | |
animation.endProgress = 1.0; | |
animation.duration = [self transitionDuration:transitionContext]; | |
[animation setTimingFunction: [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; | |
[animation setType:@"cube" ]; | |
// [animation setType:@"rippleEffect" ]; | |
animation.subtype = kCATransitionFromRight; | |
// kCATransitionFade |
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)animateMethod1 | |
{ | |
// Not always needed for some reason... | |
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:_SBR_ANIM_STAGE2_TIME]; | |
// not needed unless you have multiple animations happening with different settings | |
// [CATransaction begin]; |
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
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"]; | |
anim.fillMode = kCAFillModeForwards; | |
anim.removedOnCompletion = NO; | |
anim.byValue = [NSValue valueWithCGPoint:CGPointMake(0, 10)]; | |
anim.duration = 0.4; | |
anim.repeatCount = HUGE_VALF; | |
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; | |
anim.autoreverses = YES; | |
[self.layer addAnimation:anim forKey:@"transform"]; | |
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
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { | |
// < iOS 7 | |
} else { | |
// iOS 7+ | |
} |
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)mixInto:(id)destination | |
{ | |
unsigned int methodCount = 0; | |
Method* methods = class_copyMethodList(self, &methodCount); | |
for (int i = 0; i < methodCount; i++) { | |
Method m = methods[i]; | |
SEL name = method_getName(m); | |
IMP imp = method_getImplementation(m); |
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
#ifdef __IPHONE_7_0 | |
// ... | |
#else | |
// ... | |
#endif |
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
KEYWORDS="\@todo|\@fixme|\@hack|TODO:|HACK:|FIXME:" | |
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/i" |
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
SEL s = NSSelectorFromString(selectorName); | |
[anObject performSelector:s]; |