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
    终于明白,“喜欢”是一种莫大的能量!
  • 相关阅读:
    文件查找和比较命令 来自: http://man.linuxde.net/find
    Docker学习计划
    Mybatis各种模糊查询
    linux下vi命令大全
    mac下的环境变量
    slf4j输出变量
    使用lombok中的log
    idea中的java web项目(添加jar包介绍)和java maven web项目目录结构
    slf4j+logback&logback.xml
    日志框架
  • 原文地址:https://www.cnblogs.com/tml839720759/p/3196954.html
Copyright © 2011-2022 走看看