iOS UIView分类

  1. .h内容
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    - (CGPoint)origin;
    - (void)setOrigin:(CGPoint)point;

    - (CGSize)size;
    - (void)setSize:(CGSize)size;

    - (CGFloat)x;
    - (void)setX:(CGFloat)x;

    - (CGFloat)y;
    - (void)setY:(CGFloat)y;

    - (CGFloat)width;
    - (void)setWidth:(CGFloat)width;

    - (CGFloat)height;
    - (void)setHeight:(CGFloat)height;

    - (CGFloat)bottom;
    - (void)setBottom:(CGFloat)bottom;

    - (CGFloat)right;
    - (void)setRight:(CGFloat)right;
  2. .m内容
    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
    - (CGPoint)origin{
    return self.frame.origin;
    }
    - (void)setOrigin:(CGPoint)origin{
    CGRect frame = self.frame;
    frame.origin = origin;
    self.frame = frame;
    }

    - (CGSize)size{
    return self.frame.size;
    }
    - (void)setSize:(CGSize)size{
    CGRect frame = self.frame;
    frame.size = size;
    self.frame = frame;
    }

    - (CGFloat)x{
    return self.frame.origin.x;
    }
    - (void)setX:(CGFloat)x{
    CGRect frame = self.frame;
    frame.origin.x = x;
    self.frame = frame;
    }

    - (CGFloat)y{
    return self.frame.origin.y;
    }
    - (void)setY:(CGFloat)y{
    CGRect frame = self.frame;
    frame.origin.y = y;
    self.frame = frame;
    }

    - (CGFloat)width{
    return self.frame.size.width;
    }
    - (void)setWidth:(CGFloat)width{
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
    }

    - (CGFloat)height{
    return self.frame.size.height;
    }
    - (void)setHeight:(CGFloat)height{
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
    }

    - (CGFloat)bottom{
    return self.frame.origin.y + self.frame.size.height;
    }
    - (void)setBottom:(CGFloat)bottom{
    CGRect frame = self.frame;
    frame.origin.y = bottom - self.frame.size.height;
    self.frame = frame;
    }

    - (CGFloat)right{
    return self.frame.origin.x + self.frame.size.width;
    }
    - (void)setRight:(CGFloat)right{
    CGRect frame = self.frame;
    frame.origin.x = right - self.frame.size.width;
    self.frame = frame;
    }
-------------本文结束感谢您的阅读-------------
最近的文章

iOS 归档缓存

代码如下: 头文件定义1234// 归档缓存内容+ (void)archiverObject:(id)object byKey:(NSString *)key withPath:(NSString *)path;// 解归档缓存内容+ (id)unarchi …

继续阅读
更早的文章

iOS 发布CocoaPods私有库

需要做的工作包括以下几点 创建一个本地的仓库,将自己的代码搞进去 将自己的代码上传到远程私有仓库中去 创建一个pods 的描述文件 .podspec 修改.podspec描述文件中的相关的描述信息 创建远程内部私有Spec Repo仓库 向私有的Spec Repo仓库中提交.podspec 在 …

继续阅读