//

//  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. jquery check box

    if ($("#eulaLine").is(':checked')) { var mobile = $("#mobile").val(); if (mobile ...

  2. chrome浏览器关闭标签页面

    chrome浏览器关闭标签页提示:Scripts may close only the windows that were opened by it. 解决办法:通过open方法进行关闭. open( ...

  3. iOS NSOperation的使用

    先给出NSOpetation的官方指导https://developer.apple.com/library/ios/documentation/Cocoa/Reference/NSOperation ...

  4. 解决虚拟机 正在决定eht0 的ip信息失败 无链接-- 添加虚拟网卡

    添加步骤:1.进入设备管理器 2.点下一步3.继续下一步 4.继续往下走

  5. 2.python基础深入(元组、字符串、列表、字典)

    一,对象与类 对象: python中一切皆为对象,所谓对象:我自己就是一个对象,我玩的电脑就是对象,玩的手机就是对象. 我们通过描述属性(特征)和行为来描述一个对象的. 在python中,一个对象的特 ...

  6. codeforces 374A Inna and Pink Pony 解题报告

    题目链接:http://codeforces.com/problemset/problem/374/A 题目意思:给出一个 n 行  m 列 的棋盘,要将放置在坐标点为(i, j)的 candy 移动 ...

  7. hdu 1879 继续畅通工程 解题报告

    题目链接:http://code.hdu.edu.cn/showproblem.php?pid=1879 这条题目我的做法与解决Constructing Roads的解法是相同的. 0 表示没有连通: ...

  8. VS2010 error C3861: “exit”: 找不到标识符

    #include <stdlib.h> 可以解决问题

  9. svn: warning: 'xxxxxx' is already under version control

    [root@NGINX-APACHE-SVN pm]# svn status ? plugins ? files ? images ? data ? resources [root@NGINX-APA ...

  10. Java创建Web项目

    首先下载Tomcat服务,用来运行JAVA程序,跟windows中的IIS类似 下载地址:tomcat.apache.org ,最好下载ZIP压缩版的,解压后就可以直接用.如下图: 检查Tomcat是 ...