zoukankan      html  css  js  c++  java
  • 一个实用的UIView的类别

    //
    //  FrameAccessor.h
    //  FrameAccessor
    //
    //  Created by Alex Denisov on 18.03.12.
    //  Copyright (c) 2013 okolodev.org. All rights reserved.
    //
    
    #if (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
       #import <UIKit/UIKit.h>
       #define View UIView
    #else
       #import <Foundation/Foundation.h>
       #define View NSView
    #endif
    
    @interface UIView (FrameAccessor)
    
    - (CGPoint)origin;
    - (void)setOrigin:(CGPoint)newOrigin;
    - (CGSize)size;
    - (void)setSize:(CGSize)newSize;
    
    - (CGFloat)x;
    - (void)setX:(CGFloat)newX;
    - (CGFloat)y;
    - (void)setY:(CGFloat)newY;
    
    - (CGFloat)height;
    - (void)setHeight:(CGFloat)newHeight;
    - (CGFloat)width;
    - (void)setWidth:(CGFloat)newWidth;
    
    - (CGFloat)bottom;
    - (CGFloat)right;
    
    @end
    //  FrameAccessor.m
    //  FrameAccessor
    //
    //  Created by Alex Denisov on 18.03.12.
    //  Copyright (c) 2013 okolodev.org. All rights reserved.
    //
    
    #import "FrameAccessor.h"
    
    @implementation UIView (FrameAccessor)
    
    - (CGPoint)origin {
       return self.frame.origin;
    }
    
    - (void)setOrigin:(CGPoint)newOrigin {
       CGRect newFrame = self.frame;
       newFrame.origin = newOrigin;
       self.frame = newFrame;
    }
    
    - (CGSize)size {
       return self.frame.size;
    }
    
    - (void)setSize:(CGSize)newSize {
       CGRect newFrame = self.frame;
       newFrame.size = newSize;
       self.frame = newFrame;
    }
    
    - (CGFloat)x {
       return self.frame.origin.x;
    }
    
    - (void)setX:(CGFloat)newX {
       CGRect newFrame = self.frame;
       newFrame.origin.x = newX;
       self.frame = newFrame;
    }
    
    - (CGFloat)y {
       return self.frame.origin.y;
    }
    
    - (void)setY:(CGFloat)newY {
       CGRect newFrame = self.frame;
       newFrame.origin.y = newY;
       self.frame = newFrame;
    }
    
    - (CGFloat)height {
       return self.frame.size.height;
    }
    
    - (void)setHeight:(CGFloat)newHeight {
       CGRect newFrame = self.frame;
       newFrame.size.height = newHeight;
       self.frame = newFrame;
    }
    
    - (CGFloat)width {
       return self.frame.size.width;
    }
    
    - (void)setWidth:(CGFloat)newWidth {
       CGRect newFrame = self.frame;
       newFrame.size.width = newWidth;
       self.frame = newFrame;
    }
    
    - (CGFloat)bottom {
       return self.frame.origin.y + self.frame.size.height;
    }
    
    - (CGFloat)right {
       return self.frame.origin.x + self.frame.size.width;
    }
    
    @end
    终于明白,“喜欢”是一种莫大的能量!
  • 相关阅读:
    R语言数据集合
    转:EXCEL中如何获取从某一字符开始到最右边字符串
    转:EXCEL打乱顺序
    转:excel中怎样做柱状图
    转:linux复制/剪切文件到另一个文件夹
    转:Linux常用命令
    转:怎么在一张PPT里设置很多步骤出现的内容呀
    禅道分析
    转:BUG的严重级别分类 BUG状态标准
    转:Bug的严重等级和优先级
  • 原文地址:https://www.cnblogs.com/tml839720759/p/3196954.html
Copyright © 2011-2022 走看看