graphics.drawRect()方法

drawRect方法的官方API文档描述

drawRect
public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Draws the outline of the specified rectangle. The left and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height. The rectangle is drawn using the graphics context‘s current color.
Parameters:
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.

width和height的描述是错误的。

实践告诉我们,width,height参数应该是右下角的点的坐标。

时间: 2024-08-02 07:00:21

graphics.drawRect()方法的相关文章

iOS的layoutSubviews和drawRect方法何时调用

layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews.2.addSubview会触发layoutSubviews.3.设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化.4.滚动一个UIScrollView会触发layoutSubviews.5.旋转Screen会触发父UIView上的layoutSubviews事件.6.改变一个UIView大小的时候也会触发父UIView上的layoutS

关于layoutSubviews以及drawRect方法

首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews. 2.addSubview会触发layoutSubviews.3.设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化.4.滚动一个UIScrollView会触发layoutSubviews.5.旋转Screen会触发父UIView上的lay

UIView的layoutSubviews和drawRect方法何时调用 ———转

转自:http://jianyu996.blog.163.com/blog/static/112114555201305113018814/ 首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews. 2.addSubview会触发layoutSubviews. 3.设置view的Frame会触发layoutSubviews,当然前提是frame的

Graphics.DrawString 方法

MSDN上的解释: 在指定位置并且用指定的 Brush 和 Font 对象绘制指定的文本字符串. public void DrawString( string s, Font font, Brush brush, float x, float y ) MSDN上的实例: public void DrawStringFloat(PaintEventArgs e) { // Create string to draw . String drawString = "Sample Text";

UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout 还有drawRect方法

转自:http://blog.sina.com.cn/s/blog_a573f7990101cdpe.html 1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到  UIGraphicsGetCurrentContext,就可以画画了.而setNeedsLayout会默认调用layoutSubViews, 就可以  处理子视图中的一些数据. 综上所诉,se

UIView的layoutSubviews和drawRect方法何时调用

首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews. 2.addSubview会触发layoutSubviews. 3.设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化. 4.滚动一个UIScrollView会触发layoutSubviews. 5.旋转Screen会触发父UIView上的

iOS重写drawRect方法实现带箭头的View

创建一个UIView的子类,重写drawRect方法可以实现不规则形状的View,这里提供一个带箭头View的实现代码: ArrowView.h #import <UIKit/UIKit.h> @interface ArrowView : UIView @end ArrowView.m #import "ArrowView.h" @implementation ArrowView /* // Only override drawRect: if you perform cu

[转] C# 绘制报表,使用Graphics.DrawString 方法

原文 Graphics.DrawString 方法 在指定位置并且用指定的 Brush 和Font 对象绘制指定的文本字符串. public void DrawString( string s, Font font, Brush brush, float x, float y ) MSDN上的实例: public void DrawStringFloat(PaintEventArgs e) { // Create string to draw . String drawString = "Sam

UIView的layoutSubviews和drawRect方法

UIView的layoutSubviews和drawRect方法 首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘. layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews.2.addSubview会触发layoutSubviews.3.设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化.4.滚动一个UIScrollView会触发layoutSu