码迷,mamicode.com
首页 > 其他好文 > 详细

[CGGeometry]CGRectInset解析

时间:2015-02-07 10:21:06      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

Returns a rectangle that is smaller or larger than the source rectangle, with the same center point.

返回一个使用同样的中点比源矩形小或大的矩形。

Declaration

SWIFT

func CGRectInset(rectCGRect,
               dxCGFloat,
               dyCGFloat) -> CGRect

OBJECTIVE-C

CGRect CGRectInset CGRect rectCGFloat dxCGFloat dy );

Parameters

rect

The source CGRect structure. 源CGRect结构

dx

The x-coordinate value to use for adjusting the source rectangle. To create an inset rectangle, specify a positive value. To create a larger, encompassing rectangle, specify a negative value.

用来调整源矩形的x坐标值。规定一个正值来嵌入一个矩形。规定一个负值来创建一个更大的,包含源矩形的矩形。

dy

The y-coordinate value to use for adjusting the source rectangle. To create an inset rectangle, specify a positive value. To create a larger, encompassing rectangle, specify a negative value.

用来调整源矩形的x坐标值。规定一个正值来嵌入一个矩形。规定一个负值来创建一个更大的,包含源矩形的矩形。

Return Value

A rectangle. The origin value is offset in the x-axis by the distance specified by the dx parameter and in the y-axis by the distance specified by the dy parameter, and its size adjusted by (2*dx,2*dy), relative to the source rectangle. If dx and dy are positive values, then the rectangle’s size is decreased. If dx and dy are negative values, the rectangle’s size is increased.

一个矩形。原点值是通过dx参数确定的离x轴距离和通过dy参数确定的离y轴距离,它的大小通过相对于源矩形,(2*dx, 2*dy)来调整。如果dx和dy是正值,那么矩形的大小是减小的。如果dx和dy是负值,那么矩形的大小是增加的。

Discussion

The rectangle is standardized and then the inset parameters are applied. If the resulting rectangle would have a negative height or width, a null rectangle is returned.

如果矩形是标准的那么嵌入参数会被应用。如果结果矩形将会有一个负值的高或者宽度,将会返回一个nil空矩形。(PS:意思是说frame是正值就会应用参数,如果frame是负值则会返回一个nil)

Import Statement

import CoreGraphics

需要载入 CoreGrapghics(PS:不在UIKit里面吗)

Availability

Available in iOS 2.0 and later.

 

纯属原创,转载请注明!

[CGGeometry]CGRectInset解析

标签:

原文地址:http://www.cnblogs.com/baaingSheep/p/4278389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!