SlideShare ist ein Scribd-Unternehmen logo
1 von 32
iPhone/iPad


              Blog: http://tiny4.org/blog
                     Twitter: @Tinyfool
        Mail/Gtalk: tinyfool@gmail.com
UIView
•
•
•              UIResponder

•
    •   view
View

•     Interface Builder            view            UIView
    - (void)addSubview:(UIView *)view;
    - (void)removeFromSuperview;

•            view
    - (void)insertSubview:(UIView *)view atIndex:(int)index;
    - (void)insertSubview:(UIView *)view belowSubview:(UIView *)view;
    - (void)insertSubview:(UIView *)view aboveSubview:(UIView *)view;
    - (void)exchangeSubviewAtIndex:(int)index withSubviewAtIndex:
    (int)otherIndex;
View
• CGPoint
 •        {x,y}

• CGSize
 • {width,height}
• CGRect
CGPoint,CGSize,CGRect
CGPoint,CGSize,CGRect
UIView


•
•y
frame bounds
•           UIView

•
    - (void)drawRect:(CGRect)rect;


•
    -   (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    -   (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    -   (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    -   (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)drawRect:(CGRect)rect


•   -[UIView drawRect:]

    •                      backgroundColor

•           drawRect:

    •     rect

•                       drawRect:
•   drawRect:                               !

•
•          View
    - (void)setNeedsDisplay;

•
    - (void)setNumberOfSides:(int)sides {
         numberOfSides = sides;
         [polygonView setNeedsDisplay];
CoreGraphics                                 Quartz 2D
•   UIKit
      UIRectFill(CGRect rect);
      UIRectFrame(CGRect rect);

•   CoreGraphics:        API

•   CG      C Base API         Objective-C

•   CG      Quartz 2D
•
•                                   PDF

•        drawRect:

    •                 path   line

    •     drawRect:
        (CGContextRef)UIGraphicsGetCurrentContext(void);

    •      CG


•          drawRect:
CG

•           CG             UIKit
    •   UIColor *redColor = [UIColor redColor];
        [redColor set];

    •   UIFont *font = [UIFont systemFontOfSize:14.0];
        [myLabel setFont:font];
•   -[NSString drawAtPoint:(CGPoint)point withFont:
    (UIFont *)font]
UIImage
•       UIImage:

    •
        •   +[UIImage imageNamed:(NSString
            *)name]

    •
        •   -[UIImage initWithContentsOfFile:
            (NSString *)path]

    •
•   - [UIImage drawAtPoint:(CGPoint)point]

•   - [UIImage drawInRect:(CGRect)rect]

•   - [UIImage drawAsPatternInRect:(CGRect)rect]
•
•
•
    •   CGGraphicsContext

    •
    •
•   NSData *UIImagePNGRepresentation (UIImage * image);

•   NSData *UIImageJPGRepresentation (UIImage * image);
•
•   UITouch UIEvent

•
•
UITouch

@property(nonatomic,readonly) NSTimeInterval	timestamp;
@property(nonatomic,readonly) UITouchPhase phase;
@property(nonatomic,readonly) NSUInteger tapCount;
@property(nonatomic,readonly,retain) UIWindow
 *window;
@property(nonatomic,readonly,retain) UIView
*view;

- (CGPoint)locationInView:(UIView *)view;
- (CGPoint)previousLocationInView:(UIView *)view;
UIEvent
                                 touch




@property(nonatomic,readonly) NSTimeInterval
timestamp;

- (NSSet *)allTouches;
- (NSSet *)touchesForWindow:(UIWindow *)window;
- (NSSet *)touchesForView:(UIView *)view;
UIEvent
- (NSSet *)allTouches;
- (NSSet *)touchesForWindow:(UIWindow *)window;
- (NSSet *)touchesForView:(UIView *)view;
UIResponder
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
UIResponder
touchesBegan:withEvent:
touchesMoved:withEvent:
touchesEnded:withEvent:
touchesCancelled




touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (10)

CakePHP in iPhone App
CakePHP in iPhone AppCakePHP in iPhone App
CakePHP in iPhone App
 
31csharp
31csharp31csharp
31csharp
 
cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介cocos2d for i Phoneの紹介
cocos2d for i Phoneの紹介
 
Georgiy Shur: Bring onboarding to life
Georgiy Shur: Bring onboarding to lifeGeorgiy Shur: Bring onboarding to life
Georgiy Shur: Bring onboarding to life
 
Scaling compression2
Scaling compression2Scaling compression2
Scaling compression2
 
Snow
SnowSnow
Snow
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through Superscalarity
 
11173 rabia zafar_web_mcqs_76658_337172634
11173 rabia zafar_web_mcqs_76658_33717263411173 rabia zafar_web_mcqs_76658_337172634
11173 rabia zafar_web_mcqs_76658_337172634
 
IDC 2010 Conference Presentation
IDC 2010 Conference PresentationIDC 2010 Conference Presentation
IDC 2010 Conference Presentation
 
Proga 090525
Proga 090525Proga 090525
Proga 090525
 

Ähnlich wie iPhone/iPad开发讲座 第五讲 定制视图和多点触摸

CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads France
 
I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)Katsumi Kishikawa
 
Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Jorge Maroto
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Chris Adamson
 
Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Saulo Arruda
 
Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSKeith Norman
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhonejonmarimba
 
Getting Started with CoreGraphics
Getting Started with CoreGraphicsGetting Started with CoreGraphics
Getting Started with CoreGraphicsXamarin
 
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)anistar sung
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphICS
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder BehindJohn Wilker
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthGeoffrey Goetz
 
The not so short
The not so shortThe not so short
The not so shortAXM
 

Ähnlich wie iPhone/iPad开发讲座 第五讲 定制视图和多点触摸 (20)

CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
iOS 7 SDK特訓班
iOS 7 SDK特訓班iOS 7 SDK特訓班
iOS 7 SDK特訓班
 
I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)I phone勉強会 (2011.11.23)
I phone勉強会 (2011.11.23)
 
Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)Synchronizing without internet - Multipeer Connectivity (iOS)
Synchronizing without internet - Multipeer Connectivity (iOS)
 
Core animation
Core animationCore animation
Core animation
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
004
004004
004
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
 
Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4
 
Style vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOSStyle vs. Content and Clean Theming in iOS
Style vs. Content and Clean Theming in iOS
 
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
 
Getting Started with CoreGraphics
Getting Started with CoreGraphicsGetting Started with CoreGraphics
Getting Started with CoreGraphics
 
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
Yahoo Open Source - The Tour & Mystery of AppDevKit (MOPCON 2016)
 
I os 04
I os 04I os 04
I os 04
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene Graph
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
GCD in Action
GCD in ActionGCD in Action
GCD in Action
 
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in DepthKeeping Track of Moving Things: MapKit and CoreLocation in Depth
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
 
The not so short
The not so shortThe not so short
The not so short
 

Mehr von Hao Peiqiang

移动互联网和App的未来
移动互联网和App的未来移动互联网和App的未来
移动互联网和App的未来Hao Peiqiang
 
搜索引擎友好的网站设计
搜索引擎友好的网站设计搜索引擎友好的网站设计
搜索引擎友好的网站设计Hao Peiqiang
 
第二讲 iPhone产品战略和用户界面设计
第二讲 iPhone产品战略和用户界面设计第二讲 iPhone产品战略和用户界面设计
第二讲 iPhone产品战略和用户界面设计Hao Peiqiang
 
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版iOS平台形势和互联网企业如何应对移动浪潮 topgeek版
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版Hao Peiqiang
 
iOS平台发展形势分析 sd2.0版本
iOS平台发展形势分析 sd2.0版本iOS平台发展形势分析 sd2.0版本
iOS平台发展形势分析 sd2.0版本Hao Peiqiang
 
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别iPhone/iPad开发讲座 第六讲 多点触摸和手势识别
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别Hao Peiqiang
 
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理Hao Peiqiang
 
iPhone/iPad开发讲座 第三讲 界面和编程基础
iPhone/iPad开发讲座 第三讲 界面和编程基础iPhone/iPad开发讲座 第三讲 界面和编程基础
iPhone/iPad开发讲座 第三讲 界面和编程基础Hao Peiqiang
 
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计iPhone/iPad开发讲座 第二讲 iPhone用户界面设计
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计Hao Peiqiang
 
iPhone/iPad开发讲座 第一讲 Ios开发简介
iPhone/iPad开发讲座  第一讲 Ios开发简介iPhone/iPad开发讲座  第一讲 Ios开发简介
iPhone/iPad开发讲座 第一讲 Ios开发简介Hao Peiqiang
 
雪计算和twitter的信息传播方式
雪计算和twitter的信息传播方式雪计算和twitter的信息传播方式
雪计算和twitter的信息传播方式Hao Peiqiang
 
搜索引擎与搜索引擎营销
搜索引擎与搜索引擎营销搜索引擎与搜索引擎营销
搜索引擎与搜索引擎营销Hao Peiqiang
 
iPhone Os开发简介
iPhone Os开发简介iPhone Os开发简介
iPhone Os开发简介Hao Peiqiang
 

Mehr von Hao Peiqiang (16)

移动互联网和App的未来
移动互联网和App的未来移动互联网和App的未来
移动互联网和App的未来
 
搜索引擎友好的网站设计
搜索引擎友好的网站设计搜索引擎友好的网站设计
搜索引擎友好的网站设计
 
第二讲 iPhone产品战略和用户界面设计
第二讲 iPhone产品战略和用户界面设计第二讲 iPhone产品战略和用户界面设计
第二讲 iPhone产品战略和用户界面设计
 
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版iOS平台形势和互联网企业如何应对移动浪潮 topgeek版
iOS平台形势和互联网企业如何应对移动浪潮 topgeek版
 
iOS平台发展形势分析 sd2.0版本
iOS平台发展形势分析 sd2.0版本iOS平台发展形势分析 sd2.0版本
iOS平台发展形势分析 sd2.0版本
 
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别iPhone/iPad开发讲座 第六讲 多点触摸和手势识别
iPhone/iPad开发讲座 第六讲 多点触摸和手势识别
 
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理
iPhone/iPad开发讲座 第四讲 网络通讯和Xml处理
 
iPhone/iPad开发讲座 第三讲 界面和编程基础
iPhone/iPad开发讲座 第三讲 界面和编程基础iPhone/iPad开发讲座 第三讲 界面和编程基础
iPhone/iPad开发讲座 第三讲 界面和编程基础
 
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计iPhone/iPad开发讲座 第二讲 iPhone用户界面设计
iPhone/iPad开发讲座 第二讲 iPhone用户界面设计
 
iPhone/iPad开发讲座 第一讲 Ios开发简介
iPhone/iPad开发讲座  第一讲 Ios开发简介iPhone/iPad开发讲座  第一讲 Ios开发简介
iPhone/iPad开发讲座 第一讲 Ios开发简介
 
雪计算和twitter的信息传播方式
雪计算和twitter的信息传播方式雪计算和twitter的信息传播方式
雪计算和twitter的信息传播方式
 
搜索引擎与搜索引擎营销
搜索引擎与搜索引擎营销搜索引擎与搜索引擎营销
搜索引擎与搜索引擎营销
 
雪计算
雪计算雪计算
雪计算
 
Snow Computing
Snow ComputingSnow Computing
Snow Computing
 
Iphone Dev
Iphone DevIphone Dev
Iphone Dev
 
iPhone Os开发简介
iPhone Os开发简介iPhone Os开发简介
iPhone Os开发简介
 

iPhone/iPad开发讲座 第五讲 定制视图和多点触摸

  • 1. iPhone/iPad Blog: http://tiny4.org/blog Twitter: @Tinyfool Mail/Gtalk: tinyfool@gmail.com
  • 2. UIView • • • UIResponder • • view
  • 3. View • Interface Builder view UIView - (void)addSubview:(UIView *)view; - (void)removeFromSuperview; • view - (void)insertSubview:(UIView *)view atIndex:(int)index; - (void)insertSubview:(UIView *)view belowSubview:(UIView *)view; - (void)insertSubview:(UIView *)view aboveSubview:(UIView *)view; - (void)exchangeSubviewAtIndex:(int)index withSubviewAtIndex: (int)otherIndex;
  • 4. View • CGPoint • {x,y} • CGSize • {width,height} • CGRect
  • 9. UIView • - (void)drawRect:(CGRect)rect; • - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
  • 10.
  • 11. - (void)drawRect:(CGRect)rect • -[UIView drawRect:] • backgroundColor • drawRect: • rect • drawRect:
  • 12. drawRect: ! • • View - (void)setNeedsDisplay; • - (void)setNumberOfSides:(int)sides { numberOfSides = sides; [polygonView setNeedsDisplay];
  • 13. CoreGraphics Quartz 2D • UIKit UIRectFill(CGRect rect); UIRectFrame(CGRect rect); • CoreGraphics: API • CG C Base API Objective-C • CG Quartz 2D
  • 14. • • PDF • drawRect: • path line • drawRect: (CGContextRef)UIGraphicsGetCurrentContext(void); • CG • drawRect:
  • 15. CG • CG UIKit • UIColor *redColor = [UIColor redColor]; [redColor set]; • UIFont *font = [UIFont systemFontOfSize:14.0]; [myLabel setFont:font];
  • 16. -[NSString drawAtPoint:(CGPoint)point withFont: (UIFont *)font]
  • 17. UIImage • UIImage: • • +[UIImage imageNamed:(NSString *)name] • • -[UIImage initWithContentsOfFile: (NSString *)path] •
  • 18. - [UIImage drawAtPoint:(CGPoint)point] • - [UIImage drawInRect:(CGRect)rect] • - [UIImage drawAsPatternInRect:(CGRect)rect]
  • 19. • • • • CGGraphicsContext • •
  • 20.
  • 21. NSData *UIImagePNGRepresentation (UIImage * image); • NSData *UIImageJPGRepresentation (UIImage * image);
  • 22. • • UITouch UIEvent • •
  • 23.
  • 24. UITouch @property(nonatomic,readonly) NSTimeInterval timestamp; @property(nonatomic,readonly) UITouchPhase phase; @property(nonatomic,readonly) NSUInteger tapCount; @property(nonatomic,readonly,retain) UIWindow *window; @property(nonatomic,readonly,retain) UIView *view; - (CGPoint)locationInView:(UIView *)view; - (CGPoint)previousLocationInView:(UIView *)view;
  • 25. UIEvent touch @property(nonatomic,readonly) NSTimeInterval timestamp; - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view;
  • 26. UIEvent - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view;
  • 27. UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

Hinweis der Redaktion