(素材源码) 猫猫学iOS 之UIDynamic重力、弹性碰撞吸附等现象牛逼Demo

来源:互联网 发布:linux 文件系统 编辑:程序博客网 时间:2024/06/05 15:56

猫猫分享,必须精品

原创文章,欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243

一:效果

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

二:代码

#import "ViewController.h"#import "DemoViewController.h"@interface ViewController (){    // 功能名称的数组    NSArray *_functions;}@end@implementation ViewController- (void)viewDidLoad{    [super viewDidLoad];    _functions = @[@"吸附行为", @"推动行为", @"刚性附加行为", @"弹性附加行为", @"碰撞检测"];}#pragma mark - 数据源方法- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return _functions.count;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    // 使用Storyboard建立的UITabeViewController,其中的Cell是已经注册过的    static NSString *ID = @"Cell";    // 永远都会找到一个单元格,如果缓冲池中没有,会自动新建    /**     dequeueReusableCellWithIdentifier 直接查询可重用单元格     dequeueReusableCellWithIdentifier:forIndexPath: 查询“注册的”可重用单元格,此方法中indexPath本身没有用处        * 强制判断是否注册了单元格     如果已经注册过单元格,以上两个方法等效。     如果在StoryBoard中指定了单元格的可重用标示符,单元格的优化将有系统接管,不再需要判断cell == nil     *///    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath];//    if (cell == nil) {//        NSLog(@"come here");//        //        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];//    }    cell.textLabel.text = _functions[indexPath.row];    return cell;}#pragma mark - 代理方法- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    DemoViewController *controller = [[DemoViewController alloc] init];    // 指定标题    controller.title = _functions[indexPath.row];    controller.function = indexPath.row;    [self.navigationController pushViewController:controller animated:YES];}
#import "DemoViewController.h"#import "DemoView.h"#import "SnapView.h"#import "PushView.h"#import "AttachmentView.h"#import "SpringView.h"#import "CollisionView.h"@interface DemoViewController ()@end@implementation DemoViewController//- (void)loadView//{//    self.view = [[DemoView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];//}- (void)viewDidLoad{    [super viewDidLoad];    NSLog(@"功能代号: %d", self.function);    // 在此根据实际的功能代号加载实际的视图    DemoView *demoView = nil;    switch (self.function) {        case kDemoFunctionSnap:            demoView = [[SnapView alloc] initWithFrame:self.view.bounds];            break;        case kDemoFunctionPush:            demoView = [[PushView alloc] initWithFrame:self.view.bounds];            break;        case kDemoFunctionAttachment:            demoView = [[AttachmentView alloc] initWithFrame:self.view.bounds];            break;        case kDemoFunctionSpring:            demoView = [[SpringView alloc] initWithFrame:self.view.bounds];            break;        case kDemoFunctionCollision:            demoView = [[CollisionView alloc] initWithFrame:self.view.bounds];            break;        default:            break;    }    [self.view addSubview:demoView];}@end

主要框框就这样啦,贴出了的代码仅仅部分

三:素材代码下载地址

代码上传中。。

12 1
原创粉丝点击