UIView+LHQExtension(分类)
//
// 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(分类)的更多相关文章
- 为UIView添加分类直接改或获取控件的frame值
#import <UIKit/UIKit.h> @interface UIView (SJBExtends) @property (nonatomic,assign)CGFloat x; ...
- 通读SDWebImage②--视图分类
本文目录 UIView+WebCacheOperation UIImageView+WebCache.UIImageView+HighlightedWebCache.MKAnnotationView+ ...
- iOS获取UIView上某点的颜色值
项目需求中遇到获取UIView上某个坐标点的RGB颜色值的需求,现在把自己找到的解决方案简单总结记录一下,遇到了下面的情况: 不可移动的UIView 旋转式的UIView 滑条式的UIView 不可移 ...
- swift学习 - 分类(Extensions)
在oc中为了增强已有类的功能,我们经常使用分类.使用分类,我们可以在不破坏原有类的结构的前提下,对原有类进行模块化的扩展. 但是在swift中没有分类这种写法了.相对应的是swift中只有扩展(Ext ...
- iOS-绘制UIView之drawCGRect
写在前面 UIView对于iOS开发来讲,再熟悉不过了.也正是因为这一点,我们可能会忽略UIView一些特有方法的理解和使用.今天,笔者主要整理一下对drawRect方法的理解和使用. 默认情况下,该 ...
- iOS 添加view的分类(更加方便的设置view的位置)
点击创建UIView的分类category,这里命名为 PLExtension(为了和下面对应) view分类.h文件 #import <UIKit/UIKit.h> @interface ...
- 你真的了解UITabBarController吗?
一:首先查看一下关于UITabBarController的定义 NS_CLASS_AVAILABLE_IOS(2_0) @interface UITabBarController : UIViewCo ...
- ios - runtime运行时应用---交换方法
runtime运行时用法之一 --- 交换类的方法,此处简单写了把系统的UIView的setBackgroundColor的方法换成了自定义的pb_setBackgroundColor 首先创建UIV ...
- AutoLayout - VFL
其实很早就像整理出一份VFL的总结出来,觉得有很多东西可以写,但是真正去总结的时候发现,VFL也并没有很多东西,其实应该是在布局的过程中直接用VFL语句思考的过程比较难以形成,多数布局问题其实是在实际 ...
随机推荐
- JDBC的基本步骤
JDBC全名是Java Data Base Connectivity就是Java数据库连接,这是Java用于向数据库执行SQL语句的API,JDBC可以为多种关系型数据库提供统一的访问,而不用考虑细节 ...
- Java for LeetCode 169 Majority Element
Given an array of size n, find the majority element. The majority element is the element that appear ...
- windows电脑变成wifi热点命令
netsh wlan set hostednetwork mode=allow ssid=WIFI_NAME key="abcdefgh" netsh wlan start hos ...
- Netbeans快捷键
一.常用快捷键:1.在文件中查找指定内容 Ctrl+F2.在文件中替换指定内容 Ctrl+H3.在整个项目中查找指定内容 Ctrl+Shift+f4.自动复制整行代码 Ctrl+Shift+上/下方向 ...
- centos下安装五笔输入法的教程
[root@ok ~]# yum update [root@ok ~]# yum install ibus-table-chinese-wubi-haifeng 以上两步已经成功!! #yum ins ...
- device unauthorized & ANDROID_ADB_SERVER_PORT 问题解决
最近做安卓开发的时候,碰到了如下两个极品问题,刚开始晕头转向,仔细一研究终于解决了: FAQ1: C:\Users\xxx>adb shelladb: Env var ANDROID_ADB_S ...
- Duilib非官方更新贴~
GitHub: https://github.com/movsb/duilib.git 2014-07-20: [76a04d1] [BugFix] 修复无法解析类似<Control/&g ...
- mac 下修改Hosts文件
最近Google网站老是打不开,具体原因大家都明白,不过修改Hosts文件后,就能访问了,也算不上原创,网上一搜就能找到,自己操作记录下,希望有刚接触Mac 系统的童鞋有帮助. 第一步:打开Finde ...
- 【bzoj2002】[Hnoi2010]Bounce 弹飞绵羊 分块
[bzoj2002][Hnoi2010]Bounce 弹飞绵羊 2014年7月30日8101 Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀 ...
- mtr命令
mtr 命令详解 一般在windows 来判断网络连通性用ping 和tracert,ping的话可以来判断丢包率,tracert可以用来跟踪路由,在Linux中有一个更好的网络连通性判断工具,它可以 ...