关于 Expression is not assignable 错误
1.在 Build Phases中导入 UIKit.framework
2.在pch中导入头文件
#import <UIKit/UIKit.h>
3.写一个分类
即可解决
贴出分类代码
......h文件
#import <UIKit/UIKit.h>
@interface UIView (Extension)
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGSize size;
@property (nonatomic, assign) CGPoint origin;
@end
.....m文件
#import "UIView+Extension.h"
@implementation UIView (Extension)
- (void)setX:(CGFloat)x
{
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (void)setY:(CGFloat)y
{
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
- (CGFloat)x
{
return self.frame.origin.x;
}
- (CGFloat)y
{
return self.frame.origin.y;
}
- (void)setCenterX:(CGFloat)centerX
{
CGPoint center = self.center;
center.x = centerX;
self.center = center;
}
- (CGFloat)centerX
{
return self.center.x;
}
- (void)setCenterY:(CGFloat)centerY
{
CGPoint center = self.center;
center.y = centerY;
self.center = center;
}
- (CGFloat)centerY
{
return self.center.y;
}
- (void)setWidth:(CGFloat)width
{
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (void)setHeight:(CGFloat)height
{
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
- (CGFloat)height
{
return self.frame.size.height;
}
- (CGFloat)width
{
return self.frame.size.width;
}
- (void)setSize:(CGSize)size
{
CGRect frame = self.frame;
frame.size = size;
self.frame = frame;
}
- (CGSize)size
{
return self.frame.size;
}
- (void)setOrigin:(CGPoint)origin
{
CGRect frame = self.frame;
frame.origin = origin;
self.frame = frame;
}
- (CGPoint)origin
{
return self.frame.origin;
}
@end
关于 Expression is not assignable 错误的更多相关文章
- django 启动错误:Generator expression must be parenthesized 错误信息:
错误为: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x ...
- Uncaught Error: Syntax error, unrecognized expression: |117的js错误
117指的是js代码在浏览器运行时的出错的行号 var a="117|117" 前面的错误是由于有特殊符号“|”,用$("txtId"+a).val();去取 ...
- bullet, iOS真机编译错误error: identifier or immediate expression expected解决方法
刚才发现c3dEngine2(http://git.oschina.net/wantnon2/c3dEngine2 或 https://github.com/wantnon2/c3dEngine2)的 ...
- iOS开发OC基础:Xcode中常见英文总结,OC常见英文错误
在开发的过程中难免会遇到很多的错误,可是当看到系统给出的英文时,又不知道是什么意思.所以这篇文章总结了Xcode中常见的一些英文单词及词组,可以帮助初学的人快速了解给出的提示.多练习,就肯定能基本掌握 ...
- OC Xcode中常见的错误
在开发的过程中难免会遇到很多的错误,可是当看到系统给出的英文时,又不知道是什么意思.所以这篇文章总结了Xcode中常见的一些英文单词及词组,可以帮助初学的人快速了解给出的提示.多练习,就肯定能基本掌握 ...
- MDK常见错误详解集合
错误代码及错误信息 错误释义 error 1: Out of memory 内存溢出 error 2: Identifier expected 缺标识符 error 3: Unknown identi ...
- ORA-00936: missing expression
1.错误描述 Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Connected as scott@ORC ...
- 给 C# Expression Evaluator 增加中文变量名支持
由于一些特殊的原因,我的Expression里面需要支持中文变量名,但是C# Expression Evaluator会提示错误,在他的HelperMethods.IsAlpha()里面加上这么一段就 ...
- C语言-03-流程控制
一.选择结构 1> if语句 使用注意 ① if语句中的条件语句,不要把==和=弄混,可以把常量作为左值, 这样的话,在无用=的情况下,编译时会报错 ② if语句后若要定义新的变量或者有多条语句 ...
随机推荐
- Visual Stdio 2017增加SVN支持
实验目的 当前公司项目源码文档等内容都保存在svn上,现在是用着小乌龟在文件浏览状态中去检出和提交等操作,没有集成到vs2017中来,比较麻烦.现在要把vs2017增加svn支持,希望可以直接在IDE ...
- linux 查看磁盘文件大小
du -sh : 查看当前目录总共占的容量.而不单独列出各子项占用的容量 du -lh --max-depth=1 : 查看当前目录下一级子文件和子目录占用的磁盘容量 df -h 查看整个服务器的磁盘 ...
- stm32定时器输出移相PWM(非主从模式)
背景:由于项目需要,需要stm32输出任意相角度的PWM 前提知识: 1.stm32定时器的Tim,一般有多个OC.具体差别根据型号来定. 2.定时器的使能,理论上是多个通道同时使能 3.TIM_OC ...
- Sql题面试题
哪位大神会此题,请给出答案,十分感谢! 哪位大神会此题,请给出答案,十分感谢!
- Servlet基本知识总结
Servlet 简介 Servlet是什么? Servlet是一个Java编写的程序,此程序是基于Http协议的,并运行在web服务器上或者应用服务器上.它主要是作为web浏览器或其他Http客户端的 ...
- jupyter notebook + frp 实现内容穿透
服务器上找到frps.ini 配置如下 [common] bind_port = 7000 vhost_http_port = 8890 要穿透的笔记本的frpc.ini配置 [common] ser ...
- 理解linux网络管理命令
linux 管理命令,iproute 查看帮助文件: man ip 以下为常用帮助文件. SEE ALSO ip-address(), ip-addrlabel(), ip-l2tp(), ip-li ...
- C++编译优化备忘
基于GCC测试:http://www.tutorialspoint.com/compile_cpp11_online.php const A& a=fun() 与 A a= fun() 1.方 ...
- PyTorch进行深度学习入门
一.PyTorch是什么? 这是一个基于Python的科学计算软件包,针对两组受众: ①.NumPy的替代品,可以使用GPU的强大功能 ②.深入学习研究平台,提供最大的灵活性和速度 二.入门 ①.张量 ...
- 区块链名词解析:ICO、IFO、IEO和IMO,分别是什么呢?
区块链名词解析:ICO.IFO.IEO和IMO,分别是什么呢?本部分给出了标准答案,但其相当枯燥乏味,建议快进. ICO(Initial Coin Offering),首次代币发行,指区块链项目首次向 ...