ios 学习之你画我话绘图六 矩形
来源:互联网 发布:算法导论没有英文版 编辑:程序博客网 时间:2024/05/01 01:37
//创建画布
CGContextRef currentContext =UIGraphicsGetCurrentContext();
//创建图形可变路径句柄
CGMutablePathRef path =CGPathCreateMutable();
//设置矩形的边界
CGRect rectangle = CGRectMake(50.0f,50.0f,200.0f, 300.0f);
//添加矩形到路径中
CGPathAddRect(path,NULL, rectangle);
//添加路径到上下文中
CGContextAddPath(currentContext, path);
//填充颜色
[[UIColor colorWithRed:0.20fgreen:0.60fblue:0.80falpha:1.0f]setFill];
//设置画笔颜色
[[UIColor redColor]setStroke];
//设置边框线条宽度
CGContextSetLineWidth(currentContext,5.0f);
//画图
CGContextDrawPath(currentContext,kCGPathFillStroke);
/* 释放路径 */
CGPathRelease(path);
// UIGraphicsGetCurrentContext()
///////////////////////////////////////////////////////////////////////////////////////////////UIColor SDK//////////////////////////////////////////////////////////////////////////////////
//
// UIColor.h
// UIKit
//
// Copyright (c) 2005-2013, Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreImage/CoreImage.h>
#import <UIKit/UIKitDefines.h>
@class UIImage;
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIColor : NSObject <NSSecureCoding,NSCopying> {
@private
}
// Convenience methods for creating autoreleased colors
+ (UIColor *)colorWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
+ (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
+ (UIColor *)colorWithCGColor:(CGColorRef)cgColor;
+ (UIColor *)colorWithPatternImage:(UIImage *)image;
+ (UIColor *)colorWithCIColor:(CIColor *)ciColor NS_AVAILABLE_IOS(5_0);
// Initializers for creating non-autoreleased colors
- (UIColor *)initWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
- (UIColor *)initWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
- (UIColor *)initWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
- (UIColor *)initWithCGColor:(CGColorRef)cgColor;
- (UIColor *)initWithPatternImage:(UIImage*)image;
- (UIColor *)initWithCIColor:(CIColor *)ciColor NS_AVAILABLE_IOS(5_0);
// Some convenience methods to create colors. These colors will be as calibrated as possible.
// These colors are cached.
+ (UIColor *)blackColor; // 0.0 white
+ (UIColor *)darkGrayColor; // 0.333 white
+ (UIColor *)lightGrayColor; // 0.667 white
+ (UIColor *)whiteColor; // 1.0 white
+ (UIColor *)grayColor; // 0.5 white
+ (UIColor *)redColor; // 1.0, 0.0, 0.0 RGB
+ (UIColor *)greenColor; // 0.0, 1.0, 0.0 RGB
+ (UIColor *)blueColor; // 0.0, 0.0, 1.0 RGB
+ (UIColor *)cyanColor; // 0.0, 1.0, 1.0 RGB
+ (UIColor *)yellowColor; // 1.0, 1.0, 0.0 RGB
+ (UIColor *)magentaColor; // 1.0, 0.0, 1.0 RGB
+ (UIColor *)orangeColor; // 1.0, 0.5, 0.0 RGB
+ (UIColor *)purpleColor; // 0.5, 0.0, 0.5 RGB
+ (UIColor *)brownColor; // 0.6, 0.4, 0.2 RGB
+ (UIColor *)clearColor; // 0.0 white, 0.0 alpha
// Set the color: Sets the fill and stroke colors in the current drawing context. Should be implemented by subclassers.
- (void)set; //设置填充和画笔颜色
// Set the fill or stroke colors individually. These should be implemented by subclassers.
- (void)setFill; //设置填充颜色
- (void)setStroke; //设置画笔颜色
// Convenience methods for getting components.
// If the receiver is of a compatible color space, any non-NULL parameters are populated and 'YES' is returned. Otherwise, the parameters are left unchanged and 'NO' is returned.
- (BOOL)getWhite:(CGFloat *)white alpha:(CGFloat *)alpha NS_AVAILABLE_IOS(5_0);
- (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha NS_AVAILABLE_IOS(5_0);
- (BOOL)getRed:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha NS_AVAILABLE_IOS(5_0);
// Returns a color in the same color space as the receiver with the specified alpha component.
- (UIColor *)colorWithAlphaComponent:(CGFloat)alpha;
// Access the underlying CGColor or CIColor.
@property(nonatomic,readonly) CGColorRef CGColor;
- (CGColorRef)CGColor NS_RETURNS_INNER_POINTER;
@property(nonatomic,readonly) CIColor *CIColor NS_AVAILABLE_IOS(5_0);
@end
@interface CIColor(UIKitAdditions)
- (id)initWithColor:(UIColor *)color NS_AVAILABLE_IOS(5_0);
@end
- ios 学习之你画我话绘图六 矩形
- ios 学习之你画我话绘图七 椭圆形
- ios 学习之你画我话绘图三 画线
- ios 学习之你画我话绘图一 绘制文本和图像
- ios 学习之你画我话绘图二 熟悉下CGContextRef
- ios 学习之你画我话绘图四 读取pdf (官方代码)
- ios 学习之你画我话绘图五 构造路径基础知识
- ios绘图之矩形裁剪
- iOS开发学习之Quartz2D绘图
- iOS开发学习之Quartz2D绘图
- 我的U3D学习之旅六
- iOS开发UI-利用Quartz2D 实现基本绘图(画三角形、矩形、圆、圆弧)
- IOS绘图学习笔记
- 自定义View之绘图篇(六):Canvas那些你应该知道的变换
- IOS之绘图
- iOS 绘图之drawImage
- 【IOS学习】之六、ARC规则
- 黑马程序员-iOS视频学习之六
- JDK 7 中的 Fork/Join 模式
- 图解数据结构(3)——队
- Core Text实现编辑的时候会用到的
- 自己如何编写makefile
- 为性能
- ios 学习之你画我话绘图六 矩形
- 转义字符
- Protobuf编译原理
- 图解数据结构(2)——栈
- 使用UIImageView播放动画
- ace日志多种输出方式
- 关于系统调用open,write,read,close及库函数fopen,fwrite,fread,fclose的使用
- 自动过滤添加域名中的http
- 图解数据结构(1)——大圈表示法、动态数组和单向链表