zoukankan      html  css  js  c++  java
  • IOS 封装View的fram(X Y W H )

    @interface UIView (Extension)
    @property (nonatomic, assign) CGFloat x;
    @property (nonatomic, assign) CGFloat y;
    @property (nonatomic, assign) CGFloat width;
    @property (nonatomic, assign) CGFloat height;
    @end
    View Code
    #import "UIView+Extension.h"
    
    @implementation UIView (Extension)
    
    - (void)setX:(CGFloat)x
    {
        CGRect frame = self.frame;
        frame.origin.x = x;
        self.frame = frame;
    }
    
    - (CGFloat)x
    {
        return self.frame.origin.x;
    }
    
    - (void)setY:(CGFloat)y
    {
        CGRect frame = self.frame;
        frame.origin.y = y;
        self.frame = frame;
    }
    
    - (CGFloat)y
    {
        return self.frame.origin.y;
    }
    
    - (void)setWidth:(CGFloat)width
    {
        CGRect frame = self.frame;
        frame.size.width = width;
        self.frame = frame;
    }
    
    - (CGFloat)width
    {
        return self.frame.size.width;
    }
    
    - (void)setHeight:(CGFloat)height
    {
        CGRect frame = self.frame;
        frame.size.height = height;
        self.frame = frame;
    }
    
    - (CGFloat)height
    {
        return self.frame.size.height;
    }
    
    @end
    View Code
  • 相关阅读:
    第二次冲刺 03
    第二次冲刺 02
    第二次冲刺 01
    程序员修炼三部曲阅读笔记03
    程序员修炼三部曲阅读笔记02
    团队项目计划会议
    课堂练习—购书
    构建之法阅读笔记03
    学习进度条十二
    课堂作业找水王2
  • 原文地址:https://www.cnblogs.com/liuwj/p/6607727.html
Copyright © 2011-2022 走看看