Mais conteúdo relacionado
Semelhante a iPhone/iPad开发讲座 第五讲 定制视图和多点触摸 (20)
Mais de Hao Peiqiang (16)
iPhone/iPad开发讲座 第五讲 定制视图和多点触摸
- 1. iPhone/iPad
Blog: http://tiny4.org/blog
Twitter: @Tinyfool
Mail/Gtalk: tinyfool@gmail.com
- 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;
- 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;
- 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
•
•
- 21. • NSData *UIImagePNGRepresentation (UIImage * image);
• NSData *UIImageJPGRepresentation (UIImage * image);
- 22. •
• UITouch UIEvent
•
•
- 25. UIEvent
touch
@property(nonatomic,readonly) NSTimeInterval
timestamp;
- (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;