查看: 404|回复: 0

iOS高仿app源码:10天时候纯代码打造高仿优质《内在段子》

[复制链接]
发表于 2016-9-14 20:04:46 |未经授权,严禁转载,违者必究... | |阅读模式
段子 天时 内在 源码 代码
Github 地址

939127-bec577630d600bdd.gif

939127-bec577630d600bdd.gif

1.gif
日记:
8.30号:没怎么做工具,就是搭建了项目标架构,拉入了之前经常用的一些东西类,宏界说等等
8.30首要事项:UITabbarController+UINavigationController项目架构组建。
部门代码
8.31号:最先在8.30建的类上面填充内容,首页,这个最复杂的界面
搭建近似于今日头条首页的架构。最先抓接口,添加接口的公共参数,完美请求基类。还有几个展示的列表页的编写,由简单入难,有助于在开辟中培育自傲心
9.1号, 节制器和cell以及通俗文本图片数据的展示,以及发布界面的视图封装
9.2 - 9.4 首页的回调处置以及发现界面
9.5 - 9.7审核界面的逻辑处置和动画处置,以及发现界面的轮播图和自界说pageControl
9.8 - 9.9,搜刮界面的逻辑处置
小我中间内容的填充,部门公共空数据界面视图的处置
9.10 视频的播放和一些处所的修修补补
9.11部门动画结果的完美,例如点赞和踩,存眷等
。。以及简单的测试。9.11晚上编写博文上传Github。
要点处置:将请求到的列表数据,转化为模子数组,然后计较出模子所对应的frame数组,如许做的益处是防止CellForHeight管帐算多次,错误谬误是计较量年夜, 需要耐烦
图片浏览器,按照数据展示结构九宫格视图,然后利于自界说的NHBaseImgeView,将收集图片的请求处置逻辑全数放到该类中,还记适当SDWebimage的方式加上sd_开首的时辰,我们吃过的亏么?
处置:可以右滑来查看新的内在段子动画,详情见下面Gif图
。利于UICollectionview进行页面展示,自界说UICollectionviewFlowLayout结构
发布界面相对简单,操纵masonry

939127-a9c571614261c037.gif

939127-a9c571614261c037.gif

7.gif

939127-15a7925817178164.gif

939127-15a7925817178164.gif

939127-5e5c5fb61cc82107.gif

939127-5e5c5fb61cc82107.gif

939127-72780653c0da73cd.gif

939127-72780653c0da73cd.gif

3.gif
项目中东西类浩繁,治理类也浩繁,假如您有需要或者是想领会的话可以去Github查看我的项目源码,还有几个比力好用的Demo也开源了

首页最复杂的cell
@class NHBaseImageView;
typedef NS_ENUM(NSUInteger, NHHomeTableViewCellItemType) {
    /** 点赞*/
    NHHomeTableViewCellItemTypeLike = 1,
    /** 踩*/
    NHHomeTableViewCellItemTypeDontLike,
    /** 评论*/
    NHHomeTableViewCellItemTypeComment,
    /** 分享*/
    NHHomeTableViewCellItemTypeShare
};
@class NHHomeTableViewCellFrame , NHHomeTableViewCell, NHDiscoverSearchCommonCellFrame, NHNeiHanUserInfoModel;
@protocol NHHomeTableViewCellDelegate
/** 分类*/
- (void)homeTableViewCellDidClickCategory:(NHHomeTableViewCell *)cell;
/** 小我中间*/
- (void)homeTableViewCell:(NHHomeTableViewCell *)cell gotoPersonalCenterWithUserInfo:(NHNeiHanUserInfoModel *)userInfoModel;
/** 点击底部item*/
- (void)homeTableViewCell:(NHHomeTableViewCell *)cell didClickItemWithType:(NHHomeTableViewCellItemType)itemType;
/** 点击浏览年夜图*/
- (void)homeTableViewCell:(NHHomeTableViewCell *)cell didClickImageView:(UIImageView *)imageView currentIndex:(NSInteger)currentIndex urls:(NSArray *)urls;
/** 播放视频*/
- (void)homeTableViewCell:(NHHomeTableViewCell *)cell didClickVideoWithVideoUrl:(NSString *)videoUrl videoCover:(NHBaseImageView *)baseImageView;
@optional
/** 点击存眷*/
- (void)homeTableViewCellDidClickAttention:(NHHomeTableViewCell *)cell;
/** 删除*/
- (void)homeTableViewCellDidClickClose:(NHHomeTableViewCell *)cell;
@end
@interface NHHomeTableViewCell : NHBaseTableViewCell
/** 代办署理*/
@property (nonatomic, weak) id  delegate;
/** 首页cellFrame模子*/
@property (nonatomic, strong) NHHomeTableViewCellFrame *cellFrame;
/** 搜刮cellFrame模子*/
@property (nonatomic, strong) NHDiscoverSearchCommonCellFrame *searchCellFrame;
/** 用来判定是否有删除按钮*/
@property (nonatomic, assign) BOOL isFromHomeController;
审核,操纵贝塞尔完成一些展示上的结果
- (void)setLeftScale:(CGFloat)leftScale {
    _leftScale = leftScale;
    NSInteger leftDelta = leftScale * 100;
    self.leftL.text = [NSString stringWithFormat:@"%ld%%", leftDelta];
    CGFloat height = 10;
    UIRectCorner corner = UIRectCornerAllCorners;
    if (leftScale == 1.0) {
        corner = UIRectCornerAllCorners;
    } else {
        corner = UIRectCornerTopLeft | UIRectCornerBottomLeft;
    }
    UIBezierPath *bezierPath0 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, self.height / 2.0 - height / 2.0, 0, height) byRoundingCorners:corner cornerRadii:CGSizeMake(5.f, 5.f)];
    UIBezierPath *bezierPath1 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, self.height / 2.0 - height / 2.0, self.width * self.leftScale, height) byRoundingCorners:corner cornerRadii:CGSizeMake(5.f, 5.f)];
    CGFloat duration = 0.8;
    [self performSelector:@selector(showLeftAndRightLabel) withObject:nil afterDelay:duration];
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    animation.duration = duration;
    animation.fromValue = (__bridge id _Nullable)(bezierPath0.CGPath);
    animation.toValue = (__bridge id _Nullable)(bezierPath1.CGPath);
    [self.leftLayer addAnimation:animation forKey:@""];
}
首页滑动穿透结果
// 滑动进度
- (void)setProgress:(CGFloat)progress {
    _progress = progress;
    [self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    [_fillColor set];
    CGRect newRect = rect;
    newRect.size.width = rect.size.width * self.progress;
    UIRectFillUsingBlendMode(newRect, kCGBlendModeSourceIn);
}
附上自界说的一些类,项目中有自界说的ActionSheet,AlertView,SegmentControl,pageControl等,
贴上几段封装的关于tableView的一些代码
typedef NS_ENUM(NSInteger, NHBaseTableViewRowAnimation) {
    Fade = UITableViewRowAnimationFade,
    Right = UITableViewRowAnimationRight,           // slide in from right (or out to right)
    Left = UITableViewRowAnimationLeft,
    Top = UITableViewRowAnimationTop,
    Bottom = UITableViewRowAnimationBottom,
    None = UITableViewRowAnimationNone,            // available in iOS 3.0
    Middle = UITableViewRowAnimationMiddle,          // available in iOS 3.2.  attempts to keep cell centered in the space it will/did occupy
    Automatic = 100  // available in iOS 5.0.  chooses an appropriate animation style for you
};
@class NHBaseTableViewCell;
@interface NHBaseTableView : UITableView
- (void)nh_updateWithUpdateBlock:(void(^)(NHBaseTableView *tableView ))updateBlock;
- (UITableViewCell *)nh_cellAtIndexPath:(NSIndexPath *)indexPath;
/** 注册通俗的UITableViewCell*/
- (void)nh_registerCellClass:(Class)cellClass identifier:(NSString *)identifier;
/** 注册一个从xib中加载的UITableViewCell*/
- (void)nh_registerCellNib:(Class)cellNib nibIdentifier:(NSString *)nibIdentifier;
/** 注册一个通俗的UITableViewHeaderFooterView*/
- (void)nh_registerHeaderFooterClass:(Class)headerFooterClass identifier:(NSString *)identifier;
/** 注册一个从xib中加载的UITableViewHeaderFooterView*/
- (void)nh_registerHeaderFooterNib:(Class)headerFooterNib nibIdentifier:(NSString *)nibIdentifier;
#pragma mark - 只对已经存在的cell进行刷新,没有近似于系统的 假如行不存在,默认insert操作
/** 刷新单行、动画默认*/
- (void)nh_reloadSingleRowAtIndexPath:(NSIndexPath *)indexPath;
/** 刷新单行、动画默认*/
- (void)nh_reloadSingleRowAtIndexPath:(NSIndexPath *)indexPath animation:(NHBaseTableViewRowAnimation)animation;
/** 刷新多行、动画默认*/
- (void)nh_reloadRowsAtIndexPaths:(NSArray *)indexPaths;
/** 刷新多行、动画默认*/
- (void)nh_reloadRowsAtIndexPaths:(NSArray *)indexPaths animation:(NHBaseTableViewRowAnimation)animation;
/** 刷新某个section、动画默认*/
- (void)nh_reloadSingleSection:(NSInteger)section;
/** 刷新某个section、动画自界说*/
- (void)nh_reloadSingleSection:(NSInteger)section animation:(NHBaseTableViewRowAnimation)animation;
/** 刷新多个section、动画默认*/
- (void)nh_reloadSections:(NSArray *)sections;
/** 刷新多个section、动画自界说*/
- (void)nh_reloadSections:(NSArray *)sections animation:(NHBaseTableViewRowAnimation)animation;
#pragma mark - 对cell进行删除操作
/** 删除单行、动画默认*/
- (void)nh_deleteSingleRowAtIndexPath:(NSIndexPath *)indexPath;
/** 删除单行、动画自界说*/
- (void)nh_deleteSingleRowAtIndexPath:(NSIndexPath *)indexPath animation:(NHBaseTableViewRowAnimation)animation;
/** 删除多行、动画默认*/
- (void)nh_deleteRowsAtIndexPaths:(NSArray *)indexPaths;
/** 删除多行、动画自界说*/
- (void)nh_deleteRowsAtIndexPaths:(NSArray *)indexPaths animation:(NHBaseTableViewRowAnimation)animation;
/** 删除某个section、动画默认*/
- (void)nh_deleteSingleSection:(NSInteger)section;
简单易用的tableViewControllerGithub地址
阐发和总结
  • 这个项目做得时候比力仓皇,前后用了不到两周的时候
  • 不知道细心看的伴侣有没有意识到,这是用纯代码写的,并不是本身不习习用nib或者sb,是因为一向以来想用纯代码写一个项目
  • 所有的工具都是在公司的工作忙完的环境下编写的,比来公司不是特殊忙,所以有时候写点本身的工具,当然下班回家晚上也花了不少时候用在了这个项目上面
  • 项目中有些类和文件是之前本身清算的直接拖进去用,必然的意义上来说节流了时候
  • bug有良多,我也没怎么测直接就提交Github了,今后必定会再更新这个项目吧
  • 下一阶段的标的目的大要是swift项目了,此刻在着手一个swift小项目,前段时候写的,大要75%完成度了,也会在将来开源出来
  • 假如想交伴侣的可以加我qq3297391688,配合前进,成为一名真正的‘老司机’,本文Github地址
    点击前去本文Github地址
  • 返回顶部快速回复上一主题下一主题返回列表

    声远论坛|联系电话:0537-2311005|Archiver|手机版|小黑屋|Sitemap|声远网 |网站地图|网站地图

    鲁公网安备 37089702000485号 | 鲁ICP备 18028751号 | 互联网药品信息服务资格证:(鲁)-经营性-2022-0209 | 增值电信业务经营许可证:鲁B2-20230761号 | (鲁)职介证字[223]:第08120014号

    中国互联网违法和不良信息举报中心 | 山东省互联网违法和不良信息举报中心 | 人工智能生成合成内容标识办法

    GMT+8, 2026-5-24 04:05, Processed in 0.089404 second(s), 32 queries , Gzip On, APCu On.

    Powered by Discuz! X3.5© 2001-2026 SYUAN.COM

    快速回复 返回顶部 返回列表