fun with core graphics

Download Fun with core graphics

Post on 23-Aug-2014

1.679 views

Category:

Investor Relations

4 download

Embed Size (px)

DESCRIPTION

M.Gerasimenko, PM at SoftTechnics

TRANSCRIPT

  • Fun with CoreGraphics Project Manager, Team Lead 24.06.2011Friday, July 1, 11
  • 1. 2. 3. 4. CALayer: Glow 5. CALayer: 3D Transform + Animation 6. CAVideoLayer 7. Friday, July 1, 11
  • 1. .ttf . 2. Info.plist UIAppFonts (NSArray), : UIAppFonts ! ! c063002t.ttf 3. UIFont (UILabel, UIButton, etc): [UIFont fontWithName:@"CorpoSLig" size:Size]; UIWebView: font-family: CorpoSLig, Arial, sans-serif; CoreText: NSData *data = [[NSData alloc] initWithContentsOfFile:fontPath]; CGDataProviderRef fontProvider = CGDataProviderCreateWithCFData(data); [data release]; ! CGFontRef cgFont = CGFontCreateWithDataProvider(fontProvider); !Friday, July 1, 11
  • (Bundle) = (Folder) : 1. . 2. . 3. Xcode. 4. (lproj). 5. ...Friday, July 1, 11
  • NSString *path = [[NSBundle mainBundle] pathForResource:current ofType:@"lproj"]; self.bundle = [[NSBundle bundleWithPath:path] retain]; ... - (NSString *)localizedStringForKey:(NSString *)key comment:(NSString*)comment { ! return [self.bundle localizedStringForKey:key value:nil table:nil]; } ... #define MYLocalizedString(key, commenta) ! [[MYLocalization sharedLocalization] localizedStringForKey:(key) comment: (commenta)] ... genstrings -s MYLocalizedString ...Friday, July 1, 11
  • 1. Subclass UIWindow. @implementation CWindow #if kCLScreensaverEnabled - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { ![NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showScreenSaver) object:nil]; ![self performSelector:@selector(showScreenSaver) withObject:nil afterDelay:kCLScreensaverDelay]; ! !return [super pointInside:point withEvent:event]; } - (void)showScreenSaver { ![AppDelegate() setScreensaverShowed:YES]; } #endif @end 2. MainWindow.xib window.Friday, July 1, 11
  • CALayer 1. UIView CALayer, . 2. : CALayer UIView, . 3. : CALayer .Friday, July 1, 11
  • Glow- CALayer: UIView* myView; CALayer* Layer = myView.layer; Layer.shadowColor = MegatronColor().CGColor; Layer.masksToBounds = false; Layer.shadowOpacity = 1.0f; Layer.shadowRadius = Intensity; Layer.shouldRasterize = true; Layer.shadowOffset = CGSizeMake(0, 0);Friday, July 1, 11
  • CALayer: 3D Transform + Animation UIView transform: , . . CALayer transform: , . .Friday, July 1, 11
  • Transform+Animate: UIView *superView = [[UIApplication sharedApplication] keyWindow]; ! ! [UIView beginAnimations:nil context:NULL]; ! [UIView setAnimationDuration:0.7]; ! [UIView setAnimationDelegate:self]; ! [UIView setAnimationDidStopSelector:@selector(firstAnimationDidStop:finished:context:)]; ! [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; ! ! CALayer *layer = superView.layer; ! CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; ! rotationAndPerspectiveTransform.m34 = 1.0 / -5000; rotationAndPerspectiveTransform = ! ! CATransform3DRotate(rotationAndPerspectiveTransform, 90.0f * M_PI / ! ! ! ! ! ! ! 180.0f, 1.0f, 0.0f, 0.0f); ! ! ! rotationAndPerspectiveTransform = ! CATransform3DScale(rotationAndPerspectiveTransform, 0.92, 0.92, 1); ! layer.transform = rotationAndPerspectiveTransform; ! [UIView commitAnimations];Friday, July 1, 11
  • CAVideoLayer @interface CVideoView : UIView @property (nonatomic, retain) AVPlayer* Player; @end @implementation CVideoView @synthesize Player; -(void) dealloc { self.Player = nil; [super dealloc]; } +(Class) layerClass { return [AVPlayerLayer class]; } -(AVPlayer*) Player { return [(AVPlayerLayer*)[self layer] player]; } -(void) setPlayer:(AVPlayer*)player { [(AVPlayerLayer*)[self layer] setPlayer:player]; } @endFriday, July 1, 11
  • - (void)stepByFloatCount:(float)count { ! self.step+= count; ! ! float stepRound = roundf(self.step); ! ! if (fabs(stepRound) >= 1.0) { ! ! [self stepByCount:stepRound]; ! ! self.steps+= stepRound; ! ! self.step = self.step - stepRound; } } ... - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { ! CGPoint endPoint = [[touches anyObject] locationInView:self.view]; CGPoint dp = CGPointMake(self.startPoint.x - endPoint.x, ! ! ! ! ! ! ! ! self.startPoint.y - endPoint.y); [self.currentItem stepByFloatCount:kCLVideoDefaultStep * dp.y];! }Friday, July 1, 11
  • ! . 25 65005, www.softtechnics.bizFriday, July 1, 11