UIBezierPath: Difference between revisions

From iPhone Development Wiki
(Created page with '{{occlass|library=UIKit.framework}} UIBezierPath is a convenient object for creating rounded-rectangular shapes. == Example == <source lang="objc"> -(void)drawRect:(CGRect)…')
 
No edit summary
Line 7: Line 7:
-(void)drawRect:(CGRect)rect {
-(void)drawRect:(CGRect)rect {
   UIBezierPath* roundedRect = [UIBezierPath roundedRectBezierPath:CGRectInset(rect, 5, 5)
   UIBezierPath* roundedRect = [UIBezierPath roundedRectBezierPath:CGRectInset(rect, 5, 5)
                                                      withRoundedCorners:UIBezierPathRoundedTopLeftCorner|UIBezierPathRoundedTopRightCorner|UIBezierPathRoundedBottomLeftCorner|UIBezierPathRoundedBottomRightCorner
                                              withRoundedCorners:UIBezierPathRoundedTopLeftCorner|UIBezierPathRoundedTopRightCorner|UIBezierPathRoundedBottomLeftCorner|UIBezierPathRoundedBottomRightCorner
                                                    withCornerRadius:5.0f];
                                                withCornerRadius:5];
 
  [[UIColor blackColor] setFill];
 
  [roundedRect fill];
}
}
</source>
</source>


== Reference ==
* Header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIBezierPath.h
* How the different paths look like: http://xa1.xanga.com/70ff567527733256065727/w203670103.png
* How the different paths look like: http://xa1.xanga.com/70ff567527733256065727/w203670103.png

Revision as of 17:46, 4 October 2009


UIBezierPath is a convenient object for creating rounded-rectangular shapes.

Example

-(void)drawRect:(CGRect)rect {
  UIBezierPath* roundedRect = [UIBezierPath roundedRectBezierPath:CGRectInset(rect, 5, 5)
                                               withRoundedCorners:UIBezierPathRoundedTopLeftCorner|UIBezierPathRoundedTopRightCorner|UIBezierPathRoundedBottomLeftCorner|UIBezierPathRoundedBottomRightCorner
                                                 withCornerRadius:5];
  [[UIColor blackColor] setFill];
  [roundedRect fill];
}

Reference