怎么在xib创建的视图里面动态修改字体
2016-07-21 11:17
281 查看
写个类目,重写方法,交换方法。
+ (void)load{
Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
method_exchangeImplementations(imp, myImp);
}
- (id)myInitWithCoder:(NSCoder *)aDecode{
[self myInitWithCoder:aDecode];
if (self) {
// 部分不想改变字体的 把tag值设置成555跳过
if (self.titleLabel.tag != 555) {
CGFloat fontSize = self.titleLabel.font.pointSize;
self.titleLabel.font = [UIFont systemFontOfSize:fontSize * SizeScale];
}
}
return self;
}
+ (void)load{
Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
method_exchangeImplementations(imp, myImp);
}
- (id)myInitWithCoder:(NSCoder *)aDecode{
[self myInitWithCoder:aDecode];
if (self) {
// 部分不想改变字体的 把tag值设置成555跳过
if (self.tag != 555) {
CGFloat fontSize = self.font.pointSize;
self.font = [UIFont systemFontOfSize:fontSize * SizeScale];
}
}
return self;
}
+ (void)load{
Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
method_exchangeImplementations(imp, myImp);
}
- (id)myInitWithCoder:(NSCoder *)aDecode{
[self myInitWithCoder:aDecode];
if (self) {
// 部分不想改变字体的 把tag值设置成555跳过
if (self.titleLabel.tag != 555) {
CGFloat fontSize = self.titleLabel.font.pointSize;
self.titleLabel.font = [UIFont systemFontOfSize:fontSize * SizeScale];
}
}
return self;
}
+ (void)load{
Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
method_exchangeImplementations(imp, myImp);
}
- (id)myInitWithCoder:(NSCoder *)aDecode{
[self myInitWithCoder:aDecode];
if (self) {
// 部分不想改变字体的 把tag值设置成555跳过
if (self.tag != 555) {
CGFloat fontSize = self.font.pointSize;
self.font = [UIFont systemFontOfSize:fontSize * SizeScale];
}
}
return self;
}
相关文章推荐
- 关于mysql binlog日志的格式说明
- 【贪心】智力大冲浪
- visual studio 2015连接到MySql相关问题
- 图片放大镜特效
- iOS - + initialize 与 +load
- web 安全漏洞
- understand 4 for linux register key code 随意、任性拥有。。。。
- Android Studio快捷键整理
- form 中Enctype=multipart/form-data 的作用
- springboot简单介绍
- Maven学习 (四) 使用Nexus搭建Maven私服
- sql语句查询优化的方法-mysql
- 【Struts 2】Struts2环境搭建
- Swift传值
- adb连接手机提示unauthorized,ubs连接无授权弹窗问题
- 直接插入排序
- redis 数据类型详解 以及 redis适用场景场合
- 左右法则,i++与++i的区别
- 【Struts 2】Struts2环境搭建
- Proximal Algorithms--Proximal minimization