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

  • 6,863 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • 开的多,怎么没人讨论呢?
    Are you sure you want to
    Your message goes here
  • kjhjkhjhkjkkhkj
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
6,863
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
987
Comments
2
Likes
22

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
































Transcript

  • 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
  • 5. CGPoint,CGSize,CGRect
  • 6. CGPoint,CGSize,CGRect
  • 7. UIView • •y
  • 8. frame bounds
  • 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. - (void)drawRect:(CGRect)rect • -[UIView drawRect:] • backgroundColor • drawRect: • rect • drawRect:
  • 11. • drawRect: ! • • View - (void)setNeedsDisplay; • - (void)setNumberOfSides:(int)sides { numberOfSides = sides; [polygonView setNeedsDisplay];
  • 12. CoreGraphics Quartz 2D • UIKit UIRectFill(CGRect rect); UIRectFrame(CGRect rect); • CoreGraphics: API • CG C Base API Objective-C • CG Quartz 2D
  • 13. • • PDF • drawRect: • path line • drawRect: (CGContextRef)UIGraphicsGetCurrentContext(void); • CG • drawRect:
  • 14. CG • CG UIKit • UIColor *redColor = [UIColor redColor]; [redColor set]; • UIFont *font = [UIFont systemFontOfSize:14.0]; [myLabel setFont:font];
  • 15. • -[NSString drawAtPoint:(CGPoint)point withFont: (UIFont *)font]
  • 16. UIImage • UIImage: • • +[UIImage imageNamed:(NSString *)name] • • -[UIImage initWithContentsOfFile: (NSString *)path] •
  • 17. • - [UIImage drawAtPoint:(CGPoint)point] • - [UIImage drawInRect:(CGRect)rect] • - [UIImage drawAsPatternInRect:(CGRect)rect]
  • 18. • • • • CGGraphicsContext • •
  • 19. • NSData *UIImagePNGRepresentation (UIImage * image); • NSData *UIImageJPGRepresentation (UIImage * image);
  • 20. • • UITouch UIEvent • •
  • 21. 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;
  • 22. UIEvent touch @property(nonatomic,readonly) NSTimeInterval timestamp; - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view;
  • 23. UIEvent - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view;
  • 24. 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;
  • 25. UIResponder
  • 26. touchesBegan:withEvent:
  • 27. touchesMoved:withEvent:
  • 28. touchesEnded:withEvent:
  • 29. touchesCancelled touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event