iOS 添加view的分类(更加方便的设置view的位置)
点击创建UIView的分类category,这里命名为 PLExtension(为了和下面对应)
view分类.h文件
#import <UIKit/UIKit.h> @interface UIView (PLExtension)
@property (nonatomic, assign) CGFloat WL_width;
@property (nonatomic, assign) CGFloat WL_height;
@property (nonatomic, assign) CGFloat WL_x;
@property (nonatomic, assign) CGFloat WL_y;
@property (nonatomic, assign) CGFloat WL_centerX;
@property (nonatomic, assign) CGFloat WL_centerY; @property (nonatomic, assign) CGFloat WL_right;
@property (nonatomic, assign) CGFloat WL_bottom;
@end
.m文件
#import "UIView+PLExtension.h" @implementation UIView (WLExtension) - (CGFloat)WL_width
{
return self.frame.size.width;
} - (CGFloat)WL_height
{
return self.frame.size.height;
} - (void)setWL_width:(CGFloat)WL_width
{
CGRect frame = self.frame;
frame.size.width = WL_width;
self.frame = frame;
} - (void)setWL_height:(CGFloat)WL_height
{
CGRect frame = self.frame;
frame.size.height = WL_height;
self.frame = frame;
} - (CGFloat)WL_x
{
return self.frame.origin.x;
} - (void)setWL_x:(CGFloat)WL_x
{
CGRect frame = self.frame;
frame.origin.x = WL_x;
self.frame = frame;
} - (CGFloat)WL_y
{
return self.frame.origin.y;
} - (void)setWL_y:(CGFloat)WL_y
{
CGRect frame = self.frame;
frame.origin.y = WL_y;
self.frame = frame;
} - (CGFloat)WL_centerX
{
return self.center.x;
} - (void)setWL_centerX:(CGFloat)WL_centerX
{
CGPoint center = self.center;
center.x = WL_centerX;
self.center = center;
} - (CGFloat)WL_centerY
{
return self.center.y;
} - (void)setWL_centerY:(CGFloat)WL_centerY
{
CGPoint center = self.center;
center.y = WL_centerY;
self.center = center;
} - (CGFloat)WL_right
{
// return self.WL_x + self.WL_width;
return CGRectGetMaxX(self.frame);
} - (CGFloat)WL_bottom
{
// return self.WL_y + self.WL_height;
return CGRectGetMaxY(self.frame);
} - (void)setWL_right:(CGFloat)WL_right
{
self.WL_x = WL_right - self.WL_width;
} - (void)setWL_bottom:(CGFloat)WL_bottom
{
self.WL_y = WL_bottom - self.WL_height;
} @end
iOS 添加view的分类(更加方便的设置view的位置)的更多相关文章
- IOS添加手势识别
ios里面有手势识别,多点触控等功能,过去要实现手势识别很复杂,现在苹果为我们实现了,手势识别变得很简单 1.向视图添加手势识别器:(一般由controller完成,有时View也可以添加) 2.提供 ...
- iOS 添加功能引导图
iOS 添加功能引导图 首次安装app之后,打开app首页,有一张功能引导图,其实最简单的一种做法是,直接在这个首页上加一个蒙层图片. 在蒙层上用气泡显示文字注明功能介绍,这个蒙层图片,让你们的UI设 ...
- IOS UI-控制器的创建和控制器的View的创建
一.控制器的创建和控制器的View的创建 说明:控制器有三种创建方式,下面一一进行说明. 一.第一种创建方式(使用代码直接创建) 1.创建一个空的IOS项目. 2.为项目添加一个控制器类. 3.直接在 ...
- [iOS基础控件 - 6.11.1] - 控制器 & 控制器view
A.控制器的创建 控制器常见的创建方式有以下几种通过storyboard创建 直接创建 ViewController *vc = [[ViewController alloc] init]; ...
- Android6.0 源码修改之 仿IOS添加全屏可拖拽浮窗返回按钮
前言 之前写过屏蔽系统导航栏功能的文章,具体可看Android6.0 源码修改之屏蔽导航栏虚拟按键(Home和RecentAPP)/动态显示和隐藏NavigationBar 在某些特殊定制的版本中要求 ...
- iOS 设置View阴影
iOS 设置View投影 需要设置 颜色 阴影半径 等元素 UIView *shadowView = [[UIView alloc] init]; shadowView.frame = CGRectM ...
- ios 中UIViewController的分类
#import <UIKit/UIKit.h> #define TOPVIEWTAG 0x10000 // 导航栏的图片 @interface UIViewController (Chnb ...
- 16 ~ express ~ 添加博客分类
一,创建表结构 /schemas/categories.js var mongoose = require('mongoose') module.exports = new mongoose.S ...
- ios 添加朦层
@interface RootViewController : UIViewController { UIView *view; } -(void)createBackgroundView { vie ...
随机推荐
- 从GitLab上拉到本地仓库的项目导入到eclipse中
拉项目 在本地仓库中右键git clone,填写地址 OK, 然后在拉下来的项目上面右键检出创建dev分支. 要将新分支导入到eclipse中, 如果是没有导入过就选第三个,导入过就选第一个. 然后O ...
- # vim ~/.vimrc vim配色
Ubuntu # vim ~/.vimrc # /hom/zzx 下 set nomodeline "(这个一定要写,目前有这个安全漏洞) set ...
- java课程课后作业190606之计算最长英语单词链
一个文本文件中有N 个不同的英语单词, 我们能否写一个程序,快速找出最长的能首尾相连的英语单词链,每个单词最多只能用一次.最长的定义是:最多单词数量,和单词中字母的数量无关. 统一输入文件名称:inp ...
- Python 日期时间datetime 加一天,减一天,加减一小时一分钟,加减一年
计算年.月.日需要安装组件包 pip install python-dateutil 当前日期时间 import datetime print datetime.datetime.now() # 20 ...
- <mvc:default-servlet-handler />说明
优雅REST风格的资源URL不希望带 .html 或 .do 等后缀.由于早期的Spring MVC不能很好地处理静态资源,所以在web.xml中配置DispatcherServlet的请求映射,往往 ...
- 【分类问题中模型的性能度量(二)】超强整理,超详细解析,一文彻底搞懂ROC、AUC
文章目录 1.背景 2.ROC曲线 2.1 ROC名称溯源(选看) 2.2 ROC曲线的绘制 3.AUC(Area Under ROC Curve) 3.1 AUC来历 3.2 AUC几何意义 3.3 ...
- mysql数据库索引优化
参考 :http://www.cnblogs.com/yangmei123/archive/2016/04/10/5375723.html MySQL数据库的优化: 数据库优化的目的: ...
- recipe for target 'vmnet.ko' failed
/tmp/modconfig-60OpuH/vmnet-only/bridge.c:639:4: error: invalid preprocessing directive #atomic_inc ...
- python yield 使用示例
1.yield由于创建迭代器 def deal(): tmp = [] for i in range(20): tmp.append(i) if i % 4 == 0: yield tmp tmp = ...
- POJ 1745:Divisibility 枚举某一状态的DP
Divisibility Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11001 Accepted: 3933 Des ...