zoukankan      html  css  js  c++  java
  • 直接设置UIView的x,y,width,height...

    // 为UIView写分类
    //UIView+Extension.h
    #import <UIKit/UIKit.h>
    
    @interface UIView (Extension)
    @property (nonatomic, assign) CGFloat x;
    @property (nonatomic, assign) CGFloat y;
    @property (nonatomic, assign) CGFloat width;
    @property (nonatomic, assign) CGFloat height;
    @property (nonatomic, assign) CGSize size;
    @property (nonatomic, assign) CGPoint origin;
    @end
    
    
    //UIView+Extension.m
    #import "UIView+Extension.h"
    
    @implementation UIView (Extension)
    
    - (void)setX:(CGFloat)x
    {
        CGRect frame = self.frame;
        frame.origin.x = x;
        self.frame = frame;
    }
    
    - (void)setY:(CGFloat)y
    {
        CGRect frame = self.frame;
        frame.origin.y = y;
        self.frame = frame;
    }
    
    - (CGFloat)x
    {
        return self.frame.origin.x;
    }
    
    - (CGFloat)y
    {
        return self.frame.origin.y;
    }
    
    - (void)setWidth:(CGFloat)width
    {
        CGRect frame = self.frame;
        frame.size.width = width;
        self.frame = frame;
    }
    
    - (void)setHeight:(CGFloat)height
    {
        CGRect frame = self.frame;
        frame.size.height = height;
        self.frame = frame;
    }
    
    - (CGFloat)height
    {
        return self.frame.size.height;
    }
    
    - (CGFloat)width
    {
        return self.frame.size.width;
    }
    
    - (void)setSize:(CGSize)size
    {
        CGRect frame = self.frame;
        frame.size = size;
        self.frame = frame;
    }
    
    - (CGSize)size
    {
        return self.frame.size;
    }
    
    - (void)setOrigin:(CGPoint)origin
    {
        CGRect frame = self.frame;
        frame.origin = origin;
        self.frame = frame;
    }
    
    - (CGPoint)origin
    {
        return self.frame.origin;
    }
    @end
  • 相关阅读:
    自定义View
    Android Parcelable
    java IO
    如何安全退出已调用多个Activity的Application?
    cookie和session
    Excel 使用AutoFill提示“类Range的AutoFill方法无效”
    解决“配置系统未能初始化”问题
    Android控件第7类——对话框
    Android控件第6类——杂项控件
    Android控件第5类——ViewAnimator
  • 原文地址:https://www.cnblogs.com/521it/p/5023355.html
Copyright © 2011-2022 走看看