文章来源:淘论文网   发布者: 毕业设计   浏览量: 54



还可以点击去查询以下关键词:
[视图]    [点赞]    [工具]    [毕业]    [MDCSwipeToChoose]    [视图点赞工具毕业 - MDCSwipeToChoose]   

项目介绍:

MDCSwipeToChoose可以提供任何视图的点击“喜欢”及“不喜欢”功能,就像Tinder.app。建立一个卡片app,一个照片图片浏览器,开题报告,只需要几分钟就可以实现,不再需要花费大量时间。

使用 UIView+MDCSwipeToChoose 来添加一个滑动手势并回调任何 UIView 。
使用 MDCSwipeToChooseView 采用几行代码就能得到一个和Tinder.app几乎相同的UI

如何通过CocoaPods安装

将下列内容加入到你的Podfile中然后运行 pod install :

pod 'MDCSwipeToChoose'

点击 Yes/No

下面是一个例子,如何使用 来展示一个图片。会员能够选择点击左边来删除它,开题报告,或者选择点击右边来保存它。

Objective-C

#import <MDCSwipeToChoose/MDCSwipeToChoose.h> // ... in a view controller #pragma mark - Creating and Customizing a MDCSwipeToChooseView - (void)viewDidLoad { [super viewDidLoad]; // You can customize MDCSwipeToChooseView using MDCSwipeToChooseViewOptions. MDCSwipeToChooseViewOptions *options = [MDCSwipeToChooseViewOptions new]; options.likedText = @'Keep'; options.likedColor = [UIColor blueColor]; options.nopeText = @'Delete'; options.onPan = ^(MDCPanState *state){ if (state.thresholdRatio == 1.f && state.direction == MDCSwipeDirectionLeft) { NSLog(@'Let go now to delete the photo!'); } }; MDCSwipeToChooseView *view = [[MDCSwipeToChooseView alloc] initWithFrame:self.view.bounds options:options]; view.imageView.image = [UIImage imageNamed:@'photo']; [self.view addSubview:view]; } #pragma mark - MDCSwipeToChooseDelegate Callbacks // This is called when a user didn't fully swipe left or right. - (void)viewDidCancelSwipe:(UIView *)view { NSLog(@'Couldn't decide, huh?'); } // Sent before a choice is made. Cancel the choice by returning `NO`. Otherwise return `YES`. - (BOOL)view:(UIView *)view shouldBeChosenWithDirection:(MDCSwipeDirection)direction { if (direction == MDCSwipeDirectionLeft) { return YES; } else { // Snap the view back and cancel the choice. [UIView animateWithDuration:0.16 animations:^{ view.transform = CGAffineTransformIdentity; view.center = [view superview].center; }]; return NO; } } // This is called then a user swipes the view fully left or right. - (void)view:(UIView *)view wasChosenWithDirection:(MDCSwipeDirection)direction { if (direction == MDCSwipeDirectionLeft) { NSLog(@'Photo deleted!'); } else { NSLog(@'Photo saved!'); } }

Swift

为了从swift中使用objective-c代码,你需要使用桥接头。

#ifndef BridgingHeader_h #define BridgingHeader_h #import <UIKit/UIKit.h> #import <MDCSwipeToChoose/MDCSwipeToChoose.h> #endif import UIKit // ... in a view controller that conforms to MDCSwipeToChooseDelegate protocol override func viewDidLoad() { super.viewDidLoad() var options = MDCSwipeToChooseViewOptions() options.delegate = self options.likedText = 'Keep' options.likedColor = UIColor.blueColor() options.nopeText = 'Delete' options.onPan = { state -> Void in if state.thresholdRatio == 1 && state.direction == MDCSwipeDirection.Left { println('Photo deleted!') } } var view = MDCSwipeToChooseView(frame: self.view.bounds, options: options) view.imageView.image = UIImage(named: 'photo.png') self.view.addSubview(view) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } // This is called when a user didn't fully swipe left or right. func viewDidCancelSwipe(view: UIView) -> Void{ println('Couldn't decide, huh?') } // Sent before a choice is made. Cancel the choice by returning `false`. Otherwise return `true`. func view(view: UIView, shouldBeChosenWithDirection: MDCSwipeDirection) -> Bool{ if (shouldBeChosenWithDirection == MDCSwipeDirection.Left) { return true; } else { // Snap the view back and cancel the choice. UIView.animateWithDuration(0.16, animations: { () -> Void in view.transform = CGAffineTransformIdentity view.center = view.superview!.center }) return false; } } // This is called then a user swipes the view fully left or right. func view(view: UIView, wasChosenWithDirection: MDCSwipeDirection) -> Void{ if wasChosenWithDirection == MDCSwipeDirection.Left { println('Photo deleted!') }else{ println('Photo saved!') } }

如果你在框架中使用了CocoaPods 0.36及以上版本,你需要include下面这行

import MDCSwipeToChoose

https://github.com/modocache/MDCSwipeToChoose


这里还有:


还可以点击去查询:
[视图]    [点赞]    [工具]    [毕业]    [MDCSwipeToChoose]    [视图点赞工具毕业 - MDCSwipeToChoose]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/7740.docx
  • 上一篇:swift3.0 封装的毕业设计动画效果的开关
  • 下一篇:JDragonSoap A定制FNetworking 封装