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 ...
随机推荐
- 微信小程序手绘地图实现之《Canvas》
环境:微信SDK2.9+ + uniapp (可切换直接使用.map.js不限制环境) 正题: 先创建一个地图组件 <template> <view class="cu ...
- 1. react 简书 项目初始化
1. 创建 react 项目 npx create-react-app my-app 2. src 目录下删除 除了 index.js index.css app.js 的文件 3. 引入 style ...
- cnblogs今天挂了
刚打算搬进来常驻cnblogs,好死不死,它今天11点40分左右挂了.真是不让人省心: 今天把这后面这几个月的随笔放过来,希望能不会被清掉:
- Eclipse字体及背景色设置和工作空间字符编码设置
一.字体设置 Window->Preferences->General->Appearance->Colors and fonts->Basic->Text Fon ...
- MVC学生管理系统-阶段V(模糊查询)
项目源码 :https://download.csdn.net/download/weixin_44718300/11091042 此处省略一段话.去上一篇查看 NO01:修改list.jsp < ...
- 从架构师视角看是否该用Kotlin做服务端开发?
前言 自从Oracle收购Sun之后,对Java收费或加强控制的尝试从未间断,谷歌与Oracle围绕Java API的官司也跌宕起伏.虽然Oracle只是针对Oracle JDK8的升级收费,并释放了 ...
- Android自定义View——QQ音乐中圆形旋转碟子
1.在onMeasure中测量整个View的宽和高后,设置宽高 2.获取我们res的图片资源后,在ondraw方法中进行绘制圆形图片 3.通过Handler发送Runnable在主线程中更新UI,达到 ...
- C++ Opencv播放AVI
#include "cxcore.h" #include "cvcam.h" #include "windows.h" #include & ...
- Python连接Oracle问题
Python连接Oracle问题 1.pip install cx_oracle 2.会出现乱码问题: 方法一:配置环境变量 export NLS_LANG="SIMPLIF ...
- CodeForces 1000C Covered Points Count(区间线段覆盖问题,差分)
https://codeforces.com/problemset/problem/1000/C 题意: 有n个线段,覆盖[li,ri],最后依次输出覆盖层数为1~n的点的个数. 思路: 区间线段覆盖 ...