点击创建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的位置)的更多相关文章

  1. IOS添加手势识别

    ios里面有手势识别,多点触控等功能,过去要实现手势识别很复杂,现在苹果为我们实现了,手势识别变得很简单 1.向视图添加手势识别器:(一般由controller完成,有时View也可以添加) 2.提供 ...

  2. iOS 添加功能引导图

    iOS 添加功能引导图 首次安装app之后,打开app首页,有一张功能引导图,其实最简单的一种做法是,直接在这个首页上加一个蒙层图片. 在蒙层上用气泡显示文字注明功能介绍,这个蒙层图片,让你们的UI设 ...

  3. IOS UI-控制器的创建和控制器的View的创建

    一.控制器的创建和控制器的View的创建 说明:控制器有三种创建方式,下面一一进行说明. 一.第一种创建方式(使用代码直接创建) 1.创建一个空的IOS项目. 2.为项目添加一个控制器类. 3.直接在 ...

  4. [iOS基础控件 - 6.11.1] - 控制器 & 控制器view

    A.控制器的创建 控制器常见的创建方式有以下几种通过storyboard创建 直接创建 ViewController *vc = [[ViewController alloc] init];      ...

  5. Android6.0 源码修改之 仿IOS添加全屏可拖拽浮窗返回按钮

    前言 之前写过屏蔽系统导航栏功能的文章,具体可看Android6.0 源码修改之屏蔽导航栏虚拟按键(Home和RecentAPP)/动态显示和隐藏NavigationBar 在某些特殊定制的版本中要求 ...

  6. iOS 设置View阴影

    iOS 设置View投影 需要设置 颜色 阴影半径 等元素 UIView *shadowView = [[UIView alloc] init]; shadowView.frame = CGRectM ...

  7. ios 中UIViewController的分类

    #import <UIKit/UIKit.h> #define TOPVIEWTAG 0x10000 // 导航栏的图片 @interface UIViewController (Chnb ...

  8. 16 ~ express ~ 添加博客分类

    一,创建表结构  /schemas/categories.js var mongoose = require('mongoose')   module.exports = new mongoose.S ...

  9. ios 添加朦层

    @interface RootViewController : UIViewController { UIView *view; } -(void)createBackgroundView { vie ...

随机推荐

  1. 将java项目转成svn项目

    1.需要工具:eclipse / svn插件 2.在需要共享的项目上右键-->team-->Share Project分享项目 3.选择svn 如果需要共享成cvs选择cvs即可. 4.选 ...

  2. linux忘记密码

    linux忘记密码 Linux进入救援模式的方法 视频 centos6.5测试通过 如下 1.开机按esc进入下面界面 2.按e 3.按e 4.DM后空格加上single再回车 5.会回到这里再按b ...

  3. JVM源码分析之自定义类加载器如何拉长YGC

    概述 本文重点讲述毕玄大师在其公众号上发的一个GC问题一个jstack/jmap等不能用的case,对于毕大师那篇文章,题目上没有提到GC的那个问题,不过进入到文章里可以看到,既然文章提到了jstac ...

  4. Vulkan SDK 之 Instance

    上一篇 Vulkan SDK Demo 熟悉 粗略的了解了下,一个app是如何调用vulkan的api来展示一个立方体的,但是对其中的每一个api了解并不深刻,后面的系列会根据sample的tutor ...

  5. 基于 burpsuite的web逻辑漏洞插件开发(来自JSRC安全小课堂,柏山师傅)

    基于 burpsuite的web逻辑漏洞插件开发 BurpSuite 提供了插件开发接口,支持Java.Python.Ruby语言的扩展.虽然 BApp Store 上面已经提供了很多插件,其中也不乏 ...

  6. DevOps专题|Lua引擎打造超轻量级客户端

    Lua 作为一门轻量级脚本语言,源码使用标准C语言发布,语法简洁,非常适合嵌入式.客户端.游戏等场景. Lua引擎语言特点 轻量级 源码简单,以lua最新版5.3.5为例,加上lua自身提供的lib库 ...

  7. Codeforces Round #604 (Div. 2) 部分题解

    链接:http://codeforces.com/contest/1265 A. Beautiful String A string is called beautiful if no two con ...

  8. 尝试用kotlin做一个app(写在前面)

    学kotlin的目的好像就是做一个app,不一定有什么想做的项目,只是单纯想掌握这一门技术,确切地说只是单纯想学会做app.对于概念的东西,我也没兴趣深究,用得到的学一下,用不到的,就算了.我也不知道 ...

  9. 好文推荐:终于有人把Elasticsearch原理讲透了

    专注于Java领域优质技术,欢迎关注 作者:channingbreeze 转自公号:互联网侦察 小史是一个非科班的程序员,虽然学的是电子专业,但是通过自己的努力成功通过了面试,现在要开始迎接新生活了. ...

  10. Maven:A cycle was detected in the build path of project 'xxx'. The cycle consists of projects {xx}

    以下这个错误是在Eclipse中导入多个相互依赖的工程时出现的“循环依赖问题”:A cycle was detected in the build path of project 'xxx'. The ...