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 ...
随机推荐
- multi-layer perceptrons, MLP)模型,CvANN_MLP。
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <ope ...
- ORA-00911
直接在PLSQL运行没问题,在java程序里面运行就报错:ORA-00911 select * from mytable; 亲测,改为: select * from mytable 看到区别没,去掉: ...
- Python 中 使用 HTMLTestRunner 模块生成测试报告
使用 HTMLTestRunner 模块可以生成测试报告,但是系统自带的报告不详细,不好看,所以找了一份详细的报告 HTMLTestRunner 模板,直接导入就能使用 两种方法生成HTML报告,都 ...
- 【转】TransactionScope事务处理方法介绍及.NET Core中的注意事项
什么是TransactionScope呢? TransactionScope作为System.Transactions的一部分被引入到.NET 2.0.同时SqlClient for .NET Cor ...
- OC Swift混编-Swift.h File not found
https://www.jianshu.com/p/f860fe1718ca 2016.09.13 11:53* 字数 266 阅读 1935评论 1喜欢 1 今天碰到个神坑,本人项目是OC项目,最近 ...
- iOS下JS与原生的交互一
本篇主要讲的是UIWebView和JS的交互,在下一节会有wkWebView和JS交互的详解https://www.cnblogs.com/llhlj/p/9144110.html JS调用原生OC ...
- UVA_11525 树状数组的活用 二分
我们知道1——k有K!种排列,现在给定k和n,要你按字典序输出 第n种排列的数列 而且题目给的 n是 n=S1(k-1)!+S2(k-2)!+...+Sk-1*1!+Sk*0!(0=<Si< ...
- LeetCode——39. 组合总和
给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candidates 中的数字可以无限制重复被选 ...
- Centos7.4系统 httpd模式搭建文件服务器
环境:服务环境:centos7.4 说明:搭建Apache文件服务器,下载路径为/opt/ymyg(下载路径根据实际需要自己定义) 步骤: 1.安装httpd服务 [root@localhost ...
- POJ - 1127 Jack Straws(几何)
题意:桌子上放着n根木棍,已知木棍两端的坐标.给定几对木棍,判断每对木棍是否相连.当两根木棍之间有公共点或可以通过相连的木棍间接的连在一起,则认为是相连的. 分析: 1.若线段i与j平行,且有部分重合 ...