//

//  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. css+div绝对定位

    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" ...

  2. MyBatis3: There is no getter for property named 'code' in 'class java.lang.String'

    mybatis3  : mysql文如下,传入参数为string类型时‘preCode’,运行报错为:There is no getter for property named 'preCode' i ...

  3. iOS和android游戏纹理优化和内存优化(cocos2d-x)(转载)

    转自http://blog.csdn.net/langresser_king/article/details/8426708 (未完成) 1.2d游戏最占内存的无疑是图片资源. 2.cocos2d-x ...

  4. MPlayer-ww 增加边看边剪切功能

    解压到 D:\MPlayer-ww 运行 copy_font.bat 安装字体 LED_font.ttf 双击 MPlayer_ww_openWith.reg 添加右键播放功能 outformat.i ...

  5. mybatis异常:Improper inline parameter map format. Should be: #{propName,attr1=val1,attr2=val2}问题分析及解决

    转载自:http://blog.csdn.net/jackpk/article/details/44158701 mybatis异常:Improper inline parameter map for ...

  6. [MAC] Mac下的SVN命令行

    转载自: http://www.cnblogs.com/snandy/p/4072857.html Mac自带了SVN命令行,如我的升级到10.10(OSX yosemite)后命令行版本为1.7.1 ...

  7. 告别div,可以代替div的几个标签

    几个最常用的用来代替DIV的HTML5元素 虽说html5中大多数功能性的元素如<video><canvas><audio>等还得不到当前主流浏览器的支持(主要就是 ...

  8. Tickeys -- 找对打字的感觉 (机械键盘音效软件)

    最近发现公司里面越来越多人开始用机械键盘了,问了很多人为什么用机械键盘,主要有两种,一种是真的情怀,他们怀念十年前那种台式机硬邦邦的键盘,另外一种是因为喜欢机械键盘的声音,打字很爽.前者那真是没救了, ...

  9. Hadoop入门经典:WordCount

    转:http://blog.csdn.net/jediael_lu/article/details/38705371 以下程序在hadoop1.2.1上测试成功. 本例先将源代码呈现,然后详细说明执行 ...

  10. 在linux上安装psycopg2出错--Error: pg_config executable not found.

    这个错误可能是因为缺少PGSQL的相关库吧. 网上有很多解决办法,我最终用以下方式解决: yum install postgresql postgresql-devel python-devel