我在topview中可以引用公共属性了
但是在viewcontroller文件中又引用不了公共属性了。
编译后还会提示 重复引用xxx文件??
正在回答 回答被采纳积分+1
#import "Topview.h"
#import "ggsx.h"
@implementation Topview
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
self.backgroundColor = [UIColor blueColor];
}
return self;
}
-(void)setTitle:(NSString*)title{
UILabel *label = [[UILabel alloc]init];
label.text = title;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
UIFont *font = [UIFont systemFontOfSize:20.0];
label.font = font;
CGSize labelWH = [title sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,nil]];
label.frame = CGRectMake((UISCREEN_WIDTH-labelWH.width)/2, 20, labelWH.width, labelWH.height);
[self addSubview:label];
}
@end
#import <UIKit/UIKit.h>
@interface Topview : UIView
-(void)setTitle:(NSString*)title;
@end
- 参与学习 516 人
- 提交作业 158 份
- 解答问题 637 个
本路径采用基础+案例方式,助你解开对界面优化、数据储存、屏幕适配的疑惑。6小时团购项目实战加最新版本Swift讲解,让你掌握更多iOS开发技巧。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星