自己对于instancetype的理解和应用iOS开发的过程
来源:互联网 发布:mac照片如何归类 编辑:程序博客网 时间:2024/04/30 07:18
- (instancetype)initWithCourse:(TTCourse *)aCourse type:(TTCourseCellType)aType
{
self = [superinit];//这里是必须要写的对于重写init方法来说,开头就是这么写的不能忘记。
if (self !=nil)
{
self.course = aCourse;
self.clipsToBounds =YES;
//封面图
self.coverImageView = [[UIImageViewalloc] initWithFrame:CGRectMake(15, 15, 60 , 60)];
[self.coverImageViewsd_setImageWithURL:[NSURLURLWithString:self.course.coverURL]placeholderImage:[UIImageimageNamed:@"album_holder"]];
/**
* 圆角从2改成3
*/
self.coverImageView.layer.cornerRadius = 3.0f;
[self.contentViewaddSubview:self.coverImageView];
//曲目名字
self.titleLabel = [[UILabelalloc] initWithFrame:CGRectMake(90, 17, 200, 21)];
self.titleLabel.text =self.course.title;
self.titleLabel.font =TTCommonFont(20);
/**
* 设置字体的风格
*/
[self.contentViewaddSubview:self.titleLabel];
//作者
self.authorLabel = [[UILabelalloc] initWithFrame:CGRectMake(90, 44, 200, 15)];
self.authorLabel.text =self.course.artist;
self.authorLabel.font =TTCommonFont(12);
[self.contentViewaddSubview:self.authorLabel];
//难度
self.difficultyLabel = [[UILabelalloc] initWithFrame:CGRectMake(140, 100, 200, 20)];
self.difficultyLabel.font =TTCommonFont(14);
CGSize textSize = [self.difficultyLabel.textsizeWithAttributes:@{NSFontAttributeName :self.difficultyLabel.font}];
/**
* 72
*/
for (int i = 0; i < 5; i++)
{
UIImage* image = i <self.course.difficulty.intValue ? [UIImageimageNamed:@"icon-difficulty-active@3x.png"] : [UIImageimageNamed:@"icon-difficulty-default@3x.png"];
UIImageView* iv = [[UIImageViewalloc] initWithImage:image];
CGPoint center =self.difficultyLabel.center;
center.x += (textSize.width / 2 + i * 10)-146;
center.y=72.0;
iv.center = center;
[self.contentViewaddSubview:iv];
}
switch (aType) {
caseECourseTypePractice:
// 加入进度标识
self.progressView = [[MLVCircularProgressViewalloc] initWithFrame:CGRectMake(SYSTEM_SCREEN_WIDTH - 44, 30, 25, 25)];
self.progressView.center =self.downloadButton.center;
self.progressView.shapeColor = [UIColorcolorWithHexString:@"#cbbcad"];
self.progressView.hidden =YES;
[self.contentViewaddSubview:self.progressView];
break;
caseECourseTypeFavorite:
// 加入下载按钮
self.downloadButton = [UIButtonbuttonWithType:UIButtonTypeCustom];
[self.downloadButtonsetImage:[UIImageimageNamed:@"me_download_button"]forState:UIControlStateNormal];
self.downloadButton.frame =CGRectMake(SYSTEM_SCREEN_WIDTH - 44, 30, 44, 44);
[self.downloadButtonaddTarget:self
action:@selector(downloadAction:)
forControlEvents:UIControlEventTouchUpInside];
self.downloadButton.hidden =YES;
[self.contentViewaddSubview:self.downloadButton];
break;
caseECourseTypeCommentAndLike:
// 加入点赞和评论
break;
default:
break;
}
}
returnself;
}
这是对于自己的一个tableviewcell的自定义,这个重新写了init的方法,可以返回自己想要的产生的类型。
至于和id的区别还没有研究。id好像最终不能返回你想要的那个类。。。后续会补充
- 自己对于instancetype的理解和应用iOS开发的过程
- [IOS 开发] instancetype和id的区别
- iOS 开发 instancetype 的学习
- iOS开发48-iOS id和instancetype的使用区别
- IOS开发之对于Retain和Assign属性的理解
- 自己对于BOF和EOF的理解
- iOS dispatch_sync同步应用开发场景 自己的理解
- ios-instancetype和id的区别
- 自己对于python的理解
- 自己对于MVC开发模式的理解-2
- 对于存储过程的理解
- 【每天总结一个ios开发心得】对于Retain和Assign属性的理解
- iOS 对于block的理解
- iOS 对于block的理解
- 自己对于的理解Android的生命周期
- 自己对于mybatis的association的理解
- iOS开发 添加应用自己的字体
- iOS中instancetype和id之间的区别
- HDU 3374 String Problem (KMP+最大最小表示法)
- poj-1597
- (解题报告)入门经典2版———第三章习题1
- hibernate和Jdbc查询的区别以及hibernate查询普通查询和Hql
- [转载]初识Hadoop
- 自己对于instancetype的理解和应用iOS开发的过程
- 【coder-pig教程学习笔记4】xml文件解析
- 基于spring的方式进行读写分离思考
- 算法 -- 0-1背包问题之动态规划
- hibernate4对sql语句的一些基本操作
- 数组深入:数组与内存控制
- 【经典算法】:用递归求1*2*3*...*n
- Qt中图像的显示与基本操作
- Git分支管理模型