//

//  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. mysql lower,upper实现大小写

    mysql的lower和uppper函数可以将指定字符串转换为小写和大写 select lower('OutSpringTd') as lowerCase, upper('OutSpringTd') ...

  2. Apple Swift中英文开发资源集锦[apple swift resources]

    找到的一些Apple Swift中英文资源原文链接,希望对大家有所帮助.欢迎大家补充,原始资源链接最好! The Swift Programming Language https://develope ...

  3. python将json格式的数据转换成文本格式的数据或sql文件

    python如何将json格式的数据快速的转化成指定格式的数据呢?或者转换成sql文件? 下面的例子是将json格式的数据准换成以#_#分割的文本数据,也可用于生成sql文件. [root@bogon ...

  4. Linux开发cocos2dx程序环境搭建

    安装linux系统,ubuntu 14.04 64位 安装支持软件 sudo apt-get update sudo apt-get install git ssh vim ctags qt-sdk ...

  5. Fresco 源码分析(三) Fresco服务端处理(2) Producer具体实现的内容

    我们以mProducerFactory.newNetworkFetchProducer()为例,因为这些创建新的producer的方式类似,区别在于是否有包装的处理器,即如果当前处理器中没有正在处理的 ...

  6. gitlab安装

    [root@localhost ~]# wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rp ...

  7. CI当开启URL重写的时候,报错500 Internal Server Error

    Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...

  8. C# Window Form播放音乐的4种方式

    C#播放背景音乐通常有四种方式: 1.播放系统事件声音 2.使用System.Media.SoundPlayer播放wav------------------------仅仅是对波形音乐 3.使用MC ...

  9. 一个非常简单的返回局部字符数组的C语言程序, 请问其输出结果?

    以下是该无聊的程序: #include <stdio.h> #include <string.h> char* get_str() {     int x[10];     c ...

  10. [杂]SQL Server 之 Understanding Connection Pooling and Transactions

    A SqlConnection consists of two parts: the public instance that your code interacts with (the outer ...