//

//  UIView+LHQExtension.h

//  微博 - 李洪强(2016-5-27)

//

//  Created by vic fan on 16/5/30.

//  Copyright © 2016年 李洪强. All rights reserved.

//

#import <UIKit/UIKit.h>

@interface UIView (LHQExtension)

@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)CGFloat centerX;

@property(nonatomic,assign)CGFloat centerY;

@end

---------------------------------------------------------

//

//  UIView+LHQExtension.m

//  微博 - 李洪强(2016-5-27)

//

//  Created by vic fan on 16/5/30.

//  Copyright © 2016年 李洪强. All rights reserved.

//

#import "UIView+LHQExtension.h"

@implementation UIView (LHQExtension)

- (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;

}

- (void)setCenterX:(CGFloat)centerX{

CGPoint point = self.center;

point.x = centerX;

self.center = point;

}

- (CGFloat)centerX{

return self.center.x;

}

- (void)setCenterY:(CGFloat)centerY{

CGPoint point = self.center;

point.y = centerY;

self.center = point;

}

- (CGFloat)centerY{

return self.center.y;

}

- (void)setSize:(CGSize)size{

CGRect frame = self.frame;

frame.size = size;

self.frame = frame;

}

- (CGSize)size{

return self.frame.size;

}

@end

UIView+LHQExtension(分类)的更多相关文章

  1. 为UIView添加分类直接改或获取控件的frame值

    #import <UIKit/UIKit.h> @interface UIView (SJBExtends) @property (nonatomic,assign)CGFloat x; ...

  2. 通读SDWebImage②--视图分类

    本文目录 UIView+WebCacheOperation UIImageView+WebCache.UIImageView+HighlightedWebCache.MKAnnotationView+ ...

  3. iOS获取UIView上某点的颜色值

    项目需求中遇到获取UIView上某个坐标点的RGB颜色值的需求,现在把自己找到的解决方案简单总结记录一下,遇到了下面的情况: 不可移动的UIView 旋转式的UIView 滑条式的UIView 不可移 ...

  4. swift学习 - 分类(Extensions)

    在oc中为了增强已有类的功能,我们经常使用分类.使用分类,我们可以在不破坏原有类的结构的前提下,对原有类进行模块化的扩展. 但是在swift中没有分类这种写法了.相对应的是swift中只有扩展(Ext ...

  5. iOS-绘制UIView之drawCGRect

    写在前面 UIView对于iOS开发来讲,再熟悉不过了.也正是因为这一点,我们可能会忽略UIView一些特有方法的理解和使用.今天,笔者主要整理一下对drawRect方法的理解和使用. 默认情况下,该 ...

  6. iOS 添加view的分类(更加方便的设置view的位置)

    点击创建UIView的分类category,这里命名为 PLExtension(为了和下面对应) view分类.h文件 #import <UIKit/UIKit.h> @interface ...

  7. 你真的了解UITabBarController吗?

    一:首先查看一下关于UITabBarController的定义 NS_CLASS_AVAILABLE_IOS(2_0) @interface UITabBarController : UIViewCo ...

  8. ios - runtime运行时应用---交换方法

    runtime运行时用法之一 --- 交换类的方法,此处简单写了把系统的UIView的setBackgroundColor的方法换成了自定义的pb_setBackgroundColor 首先创建UIV ...

  9. AutoLayout - VFL

    其实很早就像整理出一份VFL的总结出来,觉得有很多东西可以写,但是真正去总结的时候发现,VFL也并没有很多东西,其实应该是在布局的过程中直接用VFL语句思考的过程比较难以形成,多数布局问题其实是在实际 ...

随机推荐

  1. There is no getter for property named 'purchaseApplyId' in 'class java.lang.Long'

    mapper.xml: <delete id="deleteByPurchaseAppyId" parameterType="Long"> < ...

  2. 如何分割一个utf8字符串(保证单个汉字的完整性)

    std::list<std::string> split_utf8_string(const std::string& text) { std::list<std::stri ...

  3. 理解和解决MySQL乱码问题

    本文将详细介绍MySQL乱码的成因和具体的解决方案 在阅读本文之前,强烈建议对字符集编码概念还比较模糊的同学 阅读下博主之前对相关概念的一篇科普:十分钟搞清字符集和字符编码 MySQL出现乱码的原因 ...

  4. C语言字符串处理

    一. C语言中,为什么字符串可以赋值给字符指针变量 char *p,a='5';p=&a;                     //显然是正确的,p="abcd";   ...

  5. [Android Memory] App调试内存泄露之Context篇(上)

    转载自:http://www.cnblogs.com/qianxudetianxia/p/3645106.html Context作为最基本的上下文,承载着Activity,Service等最基本组件 ...

  6. java用代理访问

    Properties prop = System.getProperties(); prop.setProperty("http.proxyHost", "localho ...

  7. Fedora 21 install chrome

    Steps to install Google Chrome on Fedora 21 A. Create google-chrome.repo file Use this command to cr ...

  8. Linux下的ip命令,除了ifconfig还有很多

    linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...

  9. adbWireless 简单教程

    adbWireless:无线使用ADB(siir.es.adbWireless) 下载: http://www.coolapk.com/apk/siir.es.adbWireless >> ...

  10. Bluez alpha版震撼发布!

    经过Z.XML团队所有成员的不懈努力,我们的Bluez alpha版成功完成了!现在我们宣布:Bluez alpha版正式发布! 首先我们来向大家介绍下我们这个游戏: 这是一款即时RPG塔防类游戏.在 ...