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
    终于明白,“喜欢”是一种莫大的能量!
  • 相关阅读:
    sqlserver优化查询
    DateADD日期Sql
    sql 数据字段类型
    sql Server 发送邮件 错误类型及原因
    EassyUI内置方法与属性
    这货不是 for循环
    1.switch选择结构 3.多重if选择结构和switch比对 4.总结选择结构 5.使用hasNextInt()解决用户从控制台输入为非整型问题
    1.基本选择结构if 2.逻辑运算符 3.if-else 4.多重if选择结构 5.嵌套if选择结构
    编写java程序步骤
    css3
  • 原文地址:https://www.cnblogs.com/tml839720759/p/3196954.html
Copyright © 2011-2022 走看看