BBAGeometry.h
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// BBAGeometry.h
// BBAPods
//
// Created by juxunzhuo on 15/4/10.
// Copyright (c) 2015年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
CGFloat BBADimentionMake(CGFloat length);
CGSize BBASizeMake(CGFloat width, CGFloat height);
CGRect BBARectMakeCenterBased(CGFloat x, CGFloat y, CGFloat width, CGFloat height);
CGRect BBARectMakeLeftTopBased(CGFloat x, CGFloat y, CGFloat width, CGFloat height);
CGFloat BBARatioDimentionMake(CGFloat length);
CGFloat BBARatioFontSizeMake(CGFloat length);
CGFloat BBAIphone6plusRatioDimentionMake(CGFloat length);
@interface BBAGeometry : NSObject
#pragma mark - CGRect操作
/**
将矩形x、y坐标、width、height翻倍,用于转化为高清屏下的矩形
*/
+ (CGRect)doubleRect:(CGRect)aRect;
/**
将矩阵扩大指定倍数
@param aRect 原始矩阵
@param aScale 倍数
@return 扩大后倍数后矩阵
*/
+ (CGRect)multiplyRect:(CGRect)aRect scale:(CGFloat)aScale;
/**
使一个rect中的各个值均为整数,向下取整
*/
+ (CGRect)floorRect:(CGRect)aRect;
/**
使一个rect中的各个值均为整数,向上取整
*/
+ (CGRect)ceilRect:(CGRect)aRect;
/**
矩形四边各扩展len
*/
+ (CGRect)extentRect:(CGRect)rect by:(CGFloat)len;
/**
以点为中心向四边扩展成为一个矩形
@param point 指定点
@param len 扩展长度
@return 矩阵
*/
+ (CGRect)extentPoint:(CGPoint)point by:(CGFloat)len;
/**
移动矩阵
@param rect 原始矩阵
@param xdis x方向移动距离
@param ydis y方向移动距离
@return 移动后矩阵
*/
+ (CGRect)moveRect:(CGRect)rect byX:(CGFloat)xdis byY:(CGFloat)ydis;
/**
将基于子视图的cgrect转换为基于父视图的cgrect
*/
+ (CGRect)convertRectFromSubView:(CGRect)convertRect relativeRect:(CGRect)relativeRect;
#pragma mark - CGPoint操作
+ (BOOL)isPoint:(CGPoint)aPoint inSiblingFrame:(CGRect)aContainerFrame;
@end