【OBJC类扩展之尺寸】UIView+Size
2016-06-16 09:17
471 查看
import
import “UIView+Size.h”
@implementation UIView (Size)- (void)setSize:(CGSize)size;
{
CGPoint origin = [self frame].origin;
[self setFrame:CGRectMake(origin.x, origin.y, size.width, size.height)];
}
- (CGSize)size;
{
return [self frame].size;
}
- (CGFloat)left;
{
return CGRectGetMinX([self frame]);
}
- (void)setLeft:(CGFloat)x;
{
CGRect frame = [self frame];
frame.origin.x = x;
[self setFrame:frame];
}
- (CGFloat)top;
{
return CGRectGetMinY([self frame]);
}
- (void)setTop:(CGFloat)y;
{
CGRect frame = [self frame];
frame.origin.y = y;
[self setFrame:frame];
}
- (CGFloat)right;
{
return CGRectGetMaxX([self frame]);
}
- (void)setRight:(CGFloat)right;
{
CGRect frame = [self frame];
frame.origin.x = right - frame.size.width;
[self setFrame:frame];
}
- (CGFloat)bottom;
{
return CGRectGetMaxY([self frame]);
}
- (void)setBottom:(CGFloat)bottom;
{
CGRect frame = [self frame];
frame.origin.y = bottom - frame.size.height;
[self setFrame:frame];
}
- (CGFloat)centerX;
{
return [self center].x;
}
- (void)setCenterX:(CGFloat)centerX;
{
[self setCenter:CGPointMake(centerX, self.center.y)];
}
- (CGFloat)centerY;
{
return [self center].y;
}
- (void)setCenterY:(CGFloat)centerY;
{
[self setCenter:CGPointMake(self.center.x, centerY)];
}
- (CGFloat)width;
{
return CGRectGetWidth([self frame]);
}
- (void)setWidth:(CGFloat)width;
{
CGRect frame = [self frame];
frame.size.width = width;
[self setFrame:CGRectStandardize(frame)];
}
- (CGFloat)height;
{
return CGRectGetHeight([self frame]);
}
- (void)setHeight:(CGFloat)height;
{
CGRect frame = [self frame];
frame.size.height = height;
[self setFrame:CGRectStandardize(frame)];
}
@end
相关文章推荐
- UIInterfaceOrientation和UIDeviceOrientation的区别
- you must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obta
- About New land (Empire Builders)
- iOS--UIButton图片在上,文字在下
- iOS--UIButton图片在上,文字在下
- requirejs:研究笔记
- 数据库阿里连接池 druid配置详解
- UIAlertController iOS8弹出菜单用法
- solution Of 1101. Quick Sort (25)
- Java并发包中的同步队列SynchronousQueue实现原理
- Java多线程-工具篇-BlockingQueue
- UVA 11527 Unique Snowflakes
- uva348 Optimal Array Multiplication Sequence
- POJ-3368 Frequent values
- GUID 按引用传递
- 关于ucgui多应用调度框架解析
- ASIFormDataRequest的使用——上传下载
- 【LeetCode】347. Top K Frequent Elements
- leetcode Count Numbers with Unique Digits
- Ubuntu提示No such device grub rescue解决办法