Cocoa‹‰¼·¼20140621 mac¨ios§…±é€®‚³ƒ¼ƒ‰

  • View
    372

  • Download
    0

Embed Size (px)

DESCRIPTION

OS XとiOSで動くビューの作成

Text of Cocoa‹‰¼·¼20140621...

  • 1. MaciOS 2014.6.21 Cocoa @oogon / satoshi.oomori

2. 3. Cocoa0 4. 5. 6. XOJO iOSMac 53XOJO 7. 8. iPadMac 9. 10. motion editor SpriteKitSKAction MacApp Store Ver 1.0.1 https://itunes.apple.com/jp/app/motion-editor/id876088092 11. motion editor v1.1 12. motion editor 13. motion editor Ver 1.1 TODAY 14. motion editor Swift 15. motion editor https://itunes.apple.com/jp/app/motion- editor/id876088092 http://cocoaapi.hatenablog.com/entry/ motion_editor_Japanese_support_page 16. motion editor 17. 18. 19. 20. 21. 22. 23. UI 24. 2 CoreGraphics MaciOSY Spritekit 25. iOS 8,OS X 10.10 Scene KitiOS OS X http://www.slideshare.net/oogon/scene-kit- cocoa201306 26. CoreGraphics CoreGraphics 27. 28. Bezier NSBezierPathUIBezierPath 29. Color NSColorUIColor 30. NSValue point pointValue Mac CGPointValue iOS 31. Undo Redo iOSNSUndoManager ! iOS iOS 32. 33. #if TARGET_OS_IPHONE /*iOS*/ #elif TARGET_OS_MAC /*Mac*/ #endif 34. 35. 36. 37. OOOBezierPath #if TARGET_OS_IPHONE + (OOOBezierPath *)bezierPathWithOvalInRect:(CGRect)rect { return (OOOBezierPath *)[super bezierPathWithOvalInRect:(CGRect)rect]; } #elif TARGET_OS_MAC + (OOOBezierPath *)bezierPathWithOvalInRect:(NSRect)rect { return (OOOBezierPath *)[super bezierPathWithOvalInRect:NSMakeRect(rect.origin.x, (rect.origin.y), rect.size.width, rect.size.height)]; } #endif 38. OOOColor #if TARGET_OS_IPHONE @interface OOOColor : UIColor #elif TARGET_OS_MAC @interface OOOColor : NSColor #endif 39. // OOOBezierPath *framePath = (OOOBezierPath *) [OOOBezierPath bezierPathWithRect:CGRectMake(OFFSETX,OFFSETY,300.0f, 450.0f)]; ! [[OOOColor lightGrayColor] setFill]; ! [framePath stroke]; 40. OS X iOS #if TARGET_OS_IPHONE #elif TARGET_OS_MAC //Mac - (BOOL)isFlipped { return YES; } #endif FB 41. 42. OS X mouseDown: iOS touchesBegan:withEvent: CGPoint 43. OS X mouseDrag: iOS touchesMoved:withEvent: CGPoint 44. OS X mouseUp: iOS touchesEnded:withEvent: CGPoint 45. #if TARGET_OS_IPHONE - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[event allTouches] enumerateObjectsUsingBlock:^(id obj, BOOL *stop) { [self touchBeganAndMuseDown:CGPointMake([obj locationInView:self].x,[obj locationInView:self].y)]; *stop = YES; }]; } #elif TARGET_OS_MAC - (void)mouseDown:(NSEvent *)theEvent { NSPoint mouseLoc; mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; [self touchBeganAndMuseDown:CGPointMake(mouseLoc.x,mouseLoc.y)]; ! } #endif 46. -(void)touchBeganAndMuseDown:(CGPoint)touchPoint { // NSInteger loopCount = 0; touchBegin = touchPoint; OOOAppDelegate *appDelegate = [self myDelegate]; NSMutableArray *pathObjects = [appDelegate pathObjects]; ! ! } ! } 47. needsDisplay ! -(void)needsDisplay { #if TARGET_OS_IPHONE [self setNeedsDisplay]; #elif TARGET_OS_MAC [self setNeedsDisplay:YES]; #endif } 48. delegate ! -(OOOAppDelegate *)myDelegate { #if TARGET_OS_IPHONE return (OOOAppDelegate *)[[UIApplication sharedApplication] delegate]; #elif TARGET_OS_MAC return (OOOAppDelegate *)[[NSApplication sharedApplication] delegate]; #endif } 49. 50. iOSMac 51. OS X 52.