点击创建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. Junit学习使用

    InputStream in; SqlSessionFactory factory; SqlSession session; UserDao userDao; @BeforeEach public v ...

  2. Ubuntu 14.04 搭建 ftp

    一.安装ftp服务器vsftpd $sudo apt-get update $sudo apt-get install vsftpd ftp服务器使用21端口,安装成功之后查看是否打开21端口 $ s ...

  3. Adobe Photoshop CC2014 for MAC 详细破解步骤

    1,安装Adobe Photoshop CC2014 for MAC,可以断网安装,如果不断网的话,需要申请一个Adobe ID,是免费申请. 2,下载破解工具,https://sdifen.ctfi ...

  4. 一条命令解决:No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

    1.找到目录D:\android\Sdk\ndk-bundle\toolchains.(根据自己的安装路径找到) 2.该路径下打开终端执行ln -sf aarch64-linux-android-4. ...

  5. BZOJ:1927: [Sdoi2010]星际竞速

    题解:最小费用流+二分图模型: 左边表示出这个点,右边表示入这个点: #include<iostream> #include<cstdio> #include<cstri ...

  6. tf.summary可视化参数

    1.tf.summary.scalar('accuracy', accuracy) 损失值.准确率随着迭代次数的进行,其指标变化情况:一般在画loss,accuary时会用到这个函数. 2.tenso ...

  7. 使用H5搭建webapp主页面

    使用H5搭建webapp主页面 前言: 在一个h5和微信小程序火热的时代,作为安卓程序员也得涉略一下h5了,不然就要落后了,据说在简历上可以加分哦,如果没有html和css和js基础的朋友,可以自行先 ...

  8. 使用Docker构建基于centos7镜像的python环境

    Dcokerfile配置信息 ############################################## # 基于centos7构建python3运行环境 # 构建命令: 在Dock ...

  9. python刷LeetCode:9. 回文数

    难度等级:简单 题目描述: 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121输出: true示例 2: 输入: -121输出: fa ...

  10. GBDT入门

    GBDT(MART)迭代决策树入门教程 GBDT(Gradient Boosting Decision Tree) 又叫 MART(Multiple Additive Regression Tree) ...