├── DemoTableViewController.h ├── DemoTableViewController.m ├── DemoTableViewController.xib ├── PPDragDropBadgeView.gif ├── PPDragDropBadgeView.podspec ├── PPDragDropBadgeView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── PPDragDropBadgeView.xccheckout └── xcuserdata │ └── starnet.xcuserdatad │ └── xcschemes │ ├── PPDragDropBadgeView.xcscheme │ └── xcschememanagement.plist ├── PPDragDropBadgeView ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── LaunchScreen.xib ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── MenuViewController.h ├── MenuViewController.m ├── MenuViewController.xib ├── NavigationBarViewController.h ├── NavigationBarViewController.m ├── NavigationBarViewController.xib ├── PPDragDropBadgeView │ ├── PPDragDropBadgeView.bundle │ │ ├── bomb0@2x.png │ │ ├── bomb1@2x.png │ │ ├── bomb2@2x.png │ │ ├── bomb3@2x.png │ │ └── bomb4@2x.png │ ├── PPDragDropBadgeView.h │ ├── PPDragDropBadgeView.m │ └── PRTween │ │ ├── PRTween.h │ │ ├── PRTween.m │ │ ├── PRTweenTimingFunctions.h │ │ └── PRTweenTimingFunctions.m ├── SimpleViewController.h ├── SimpleViewController.m ├── SimpleViewController.xib ├── TabbarViewController.h ├── TabbarViewController.m ├── TabbarViewController.xib ├── TableViewCell.h ├── TableViewCell.m ├── TableViewCell.xib └── main.m ├── PPDragDropBadgeViewTests ├── Info.plist └── PPDragDropBadgeViewTests.m └── README.md /DemoTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoTableViewController.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 5/21/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DemoTableViewController : UITableViewController 12 | 13 | @property (nonatomic, strong) NSArray* tableData; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /DemoTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoTableViewController.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 5/21/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "DemoTableViewController.h" 10 | #import "PPDragDropBadgeView.h" 11 | #import "TableViewCell.h" 12 | 13 | @interface DemoTableViewController () 14 | 15 | 16 | @end 17 | 18 | @implementation DemoTableViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | [self.tableView registerNib:[UINib nibWithNibName:@"TableViewCell" bundle:nil] forCellReuseIdentifier:@"reuseIdentifier"]; 24 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier1"]; 25 | 26 | self.tableData = @[ 27 | @{ 28 | @"section":@"addSubview", 29 | @"identifier":@"reuseIdentifier", 30 | }, 31 | @{ 32 | @"section":@"accessoryView", 33 | @"identifier":@"reuseIdentifier1", 34 | }, 35 | ]; 36 | } 37 | 38 | - (void)didReceiveMemoryWarning { 39 | [super didReceiveMemoryWarning]; 40 | // Dispose of any resources that can be recreated. 41 | } 42 | 43 | #pragma mark - Table view data source 44 | 45 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 46 | return [self.tableData count]; 47 | } 48 | 49 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 50 | NSDictionary* info = self.tableData[indexPath.row]; 51 | 52 | 53 | TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:info[@"identifier"] forIndexPath:indexPath]; 54 | cell.textLabel.text = info[@"section"]; 55 | if ([info[@"identifier"] isEqualToString:@"reuseIdentifier"]) { 56 | cell.badgeView.text = [NSString stringWithFormat:@"%lu", indexPath.row+1]; 57 | } else { 58 | //accessoryView 59 | PPDragDropBadgeView* badge = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(10, 10, 25, 25) dragdropCompletion:^{ 60 | NSLog(@"Drag Drop Done."); 61 | }]; 62 | badge.text = [NSString stringWithFormat:@"%lu", indexPath.row+1]; 63 | 64 | //Please add to container first 65 | UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; 66 | [container addSubview:badge]; 67 | cell.accessoryView = container; 68 | } 69 | 70 | return cell; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /DemoTableViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView.gif -------------------------------------------------------------------------------- /PPDragDropBadgeView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint PPDragDropBadgeView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "PPDragDropBadgeView" 19 | s.version = "0.0.1" 20 | s.summary = "A short description of PPDragDropBadgeView." 21 | 22 | s.description = <<-DESC 23 | A longer description of PPDragDropBadgeView in Markdown format. 24 | 25 | * Think: Why did you write this? What is the focus? What does it do? 26 | * CocoaPods will be using this to generate tags, and improve search results. 27 | * Try to keep it short, snappy and to the point. 28 | * Finally, don't worry about the indent, CocoaPods strips it! 29 | DESC 30 | 31 | s.homepage = "http://EXAMPLE/PPDragDropBadgeView" 32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See http://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | s.license = "MIT (example)" 43 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | s.author = { "许文发" => "lvyexuwenfa100@126.com" } 57 | # Or just: s.author = "许文发" 58 | # s.authors = { "许文发" => "lvyexuwenfa100@126.com" } 59 | # s.social_media_url = "http://twitter.com/许文发" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | # s.platform = :ios 68 | # s.platform = :ios, "5.0" 69 | 70 | # When using multiple platforms 71 | # s.ios.deployment_target = "5.0" 72 | # s.osx.deployment_target = "10.7" 73 | 74 | 75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 76 | # 77 | # Specify the location from where the source should be retrieved. 78 | # Supports git, hg, bzr, svn and HTTP. 79 | # 80 | 81 | s.source = { :git => "http://EXAMPLE/PPDragDropBadgeView.git", :tag => "0.0.1" } 82 | 83 | 84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 85 | # 86 | # CocoaPods is smart about how it includes source code. For source files 87 | # giving a folder will include any swift, h, m, mm, c & cpp files. 88 | # For header files it will include any header in the folder. 89 | # Not including the public_header_files will make all headers public. 90 | # 91 | 92 | s.source_files = "Classes", "Classes/**/*.{h,m}" 93 | s.exclude_files = "Classes/Exclude" 94 | 95 | # s.public_header_files = "Classes/**/*.h" 96 | 97 | 98 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 99 | # 100 | # A list of resources included with the Pod. These are copied into the 101 | # target bundle with a build phase script. Anything else will be cleaned. 102 | # You can preserve files from being cleaned, please don't preserve 103 | # non-essential files like tests, examples and documentation. 104 | # 105 | 106 | # s.resource = "icon.png" 107 | # s.resources = "Resources/*.png" 108 | 109 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 110 | 111 | 112 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 113 | # 114 | # Link your library with frameworks, or libraries. Libraries do not include 115 | # the lib prefix of their name. 116 | # 117 | 118 | # s.framework = "SomeFramework" 119 | # s.frameworks = "SomeFramework", "AnotherFramework" 120 | 121 | # s.library = "iconv" 122 | # s.libraries = "iconv", "xml2" 123 | 124 | 125 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 126 | # 127 | # If your library depends on compiler flags you can set them in the xcconfig hash 128 | # where they will only apply to your library. If you depend on other Podspecs 129 | # you can include multiple dependencies to ensure it works. 130 | 131 | # s.requires_arc = true 132 | 133 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 134 | # s.dependency "JSONKit", "~> 1.4" 135 | 136 | end 137 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E44A2D8C1B0D97ED00C0A7D6 /* DemoTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E44A2D8A1B0D97ED00C0A7D6 /* DemoTableViewController.m */; }; 11 | E44A2D8D1B0D97ED00C0A7D6 /* DemoTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E44A2D8B1B0D97ED00C0A7D6 /* DemoTableViewController.xib */; }; 12 | E49E17FD1AC8F5F3008C3009 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E17FC1AC8F5F3008C3009 /* main.m */; }; 13 | E49E18001AC8F5F3008C3009 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E17FF1AC8F5F3008C3009 /* AppDelegate.m */; }; 14 | E49E18081AC8F5F3008C3009 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E49E18071AC8F5F3008C3009 /* Images.xcassets */; }; 15 | E49E180B1AC8F5F3008C3009 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = E49E18091AC8F5F3008C3009 /* LaunchScreen.xib */; }; 16 | E49E18171AC8F5F3008C3009 /* PPDragDropBadgeViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E18161AC8F5F3008C3009 /* PPDragDropBadgeViewTests.m */; }; 17 | E49E18331AC8F818008C3009 /* PPDragDropBadgeView.bundle in Resources */ = {isa = PBXBuildFile; fileRef = E49E182B1AC8F818008C3009 /* PPDragDropBadgeView.bundle */; }; 18 | E49E18341AC8F818008C3009 /* PPDragDropBadgeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E182D1AC8F818008C3009 /* PPDragDropBadgeView.m */; }; 19 | E49E18351AC8F818008C3009 /* PRTween.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E18301AC8F818008C3009 /* PRTween.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 20 | E49E18361AC8F818008C3009 /* PRTweenTimingFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = E49E18321AC8F818008C3009 /* PRTweenTimingFunctions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 21 | E4CD20AB1BE12A0B001401E6 /* TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E4CD20A91BE12A0B001401E6 /* TableViewCell.m */; }; 22 | E4CD20AC1BE12A0B001401E6 /* TableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E4CD20AA1BE12A0B001401E6 /* TableViewCell.xib */; }; 23 | E4CD20B01BE1B2CF001401E6 /* MenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E4CD20AE1BE1B2CF001401E6 /* MenuViewController.m */; }; 24 | E4CD20B11BE1B2CF001401E6 /* MenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E4CD20AF1BE1B2CF001401E6 /* MenuViewController.xib */; }; 25 | E4CD20B51BE1B447001401E6 /* SimpleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E4CD20B31BE1B447001401E6 /* SimpleViewController.m */; }; 26 | E4CD20B61BE1B447001401E6 /* SimpleViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E4CD20B41BE1B447001401E6 /* SimpleViewController.xib */; }; 27 | E4CD20BA1BE1B68E001401E6 /* NavigationBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E4CD20B81BE1B68E001401E6 /* NavigationBarViewController.m */; }; 28 | E4CD20BB1BE1B68E001401E6 /* NavigationBarViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E4CD20B91BE1B68E001401E6 /* NavigationBarViewController.xib */; }; 29 | E4CD20BF1BE1BA8B001401E6 /* TabbarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E4CD20BD1BE1BA8B001401E6 /* TabbarViewController.m */; }; 30 | E4CD20C01BE1BA8B001401E6 /* TabbarViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E4CD20BE1BE1BA8B001401E6 /* TabbarViewController.xib */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | E49E18111AC8F5F3008C3009 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = E49E17EF1AC8F5F3008C3009 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = E49E17F61AC8F5F3008C3009; 39 | remoteInfo = PPDragDropBadgeView; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | E44A2D891B0D97ED00C0A7D6 /* DemoTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DemoTableViewController.h; path = ../DemoTableViewController.h; sourceTree = ""; }; 45 | E44A2D8A1B0D97ED00C0A7D6 /* DemoTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DemoTableViewController.m; path = ../DemoTableViewController.m; sourceTree = ""; }; 46 | E44A2D8B1B0D97ED00C0A7D6 /* DemoTableViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DemoTableViewController.xib; path = ../DemoTableViewController.xib; sourceTree = ""; }; 47 | E49E17F71AC8F5F3008C3009 /* PPDragDropBadgeView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PPDragDropBadgeView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | E49E17FB1AC8F5F3008C3009 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | E49E17FC1AC8F5F3008C3009 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | E49E17FE1AC8F5F3008C3009 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 51 | E49E17FF1AC8F5F3008C3009 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 52 | E49E18071AC8F5F3008C3009 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 53 | E49E180A1AC8F5F3008C3009 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 54 | E49E18101AC8F5F3008C3009 /* PPDragDropBadgeViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PPDragDropBadgeViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | E49E18151AC8F5F3008C3009 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | E49E18161AC8F5F3008C3009 /* PPDragDropBadgeViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PPDragDropBadgeViewTests.m; sourceTree = ""; }; 57 | E49E182B1AC8F818008C3009 /* PPDragDropBadgeView.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = PPDragDropBadgeView.bundle; sourceTree = ""; }; 58 | E49E182C1AC8F818008C3009 /* PPDragDropBadgeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPDragDropBadgeView.h; sourceTree = ""; }; 59 | E49E182D1AC8F818008C3009 /* PPDragDropBadgeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPDragDropBadgeView.m; sourceTree = ""; }; 60 | E49E182F1AC8F818008C3009 /* PRTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PRTween.h; sourceTree = ""; }; 61 | E49E18301AC8F818008C3009 /* PRTween.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PRTween.m; sourceTree = ""; }; 62 | E49E18311AC8F818008C3009 /* PRTweenTimingFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PRTweenTimingFunctions.h; sourceTree = ""; }; 63 | E49E18321AC8F818008C3009 /* PRTweenTimingFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PRTweenTimingFunctions.m; sourceTree = ""; }; 64 | E4CD20A81BE12A0B001401E6 /* TableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCell.h; sourceTree = ""; }; 65 | E4CD20A91BE12A0B001401E6 /* TableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCell.m; sourceTree = ""; }; 66 | E4CD20AA1BE12A0B001401E6 /* TableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCell.xib; sourceTree = ""; }; 67 | E4CD20AD1BE1B2CF001401E6 /* MenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuViewController.h; sourceTree = ""; }; 68 | E4CD20AE1BE1B2CF001401E6 /* MenuViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuViewController.m; sourceTree = ""; }; 69 | E4CD20AF1BE1B2CF001401E6 /* MenuViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MenuViewController.xib; sourceTree = ""; }; 70 | E4CD20B21BE1B447001401E6 /* SimpleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleViewController.h; sourceTree = ""; }; 71 | E4CD20B31BE1B447001401E6 /* SimpleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleViewController.m; sourceTree = ""; }; 72 | E4CD20B41BE1B447001401E6 /* SimpleViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SimpleViewController.xib; sourceTree = ""; }; 73 | E4CD20B71BE1B68E001401E6 /* NavigationBarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationBarViewController.h; sourceTree = ""; }; 74 | E4CD20B81BE1B68E001401E6 /* NavigationBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationBarViewController.m; sourceTree = ""; }; 75 | E4CD20B91BE1B68E001401E6 /* NavigationBarViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NavigationBarViewController.xib; sourceTree = ""; }; 76 | E4CD20BC1BE1BA8B001401E6 /* TabbarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabbarViewController.h; sourceTree = ""; }; 77 | E4CD20BD1BE1BA8B001401E6 /* TabbarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabbarViewController.m; sourceTree = ""; }; 78 | E4CD20BE1BE1BA8B001401E6 /* TabbarViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TabbarViewController.xib; sourceTree = ""; }; 79 | /* End PBXFileReference section */ 80 | 81 | /* Begin PBXFrameworksBuildPhase section */ 82 | E49E17F41AC8F5F3008C3009 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | E49E180D1AC8F5F3008C3009 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | E49E17EE1AC8F5F3008C3009 = { 100 | isa = PBXGroup; 101 | children = ( 102 | E49E17F91AC8F5F3008C3009 /* PPDragDropBadgeView */, 103 | E49E18131AC8F5F3008C3009 /* PPDragDropBadgeViewTests */, 104 | E49E17F81AC8F5F3008C3009 /* Products */, 105 | ); 106 | sourceTree = ""; 107 | }; 108 | E49E17F81AC8F5F3008C3009 /* Products */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | E49E17F71AC8F5F3008C3009 /* PPDragDropBadgeView.app */, 112 | E49E18101AC8F5F3008C3009 /* PPDragDropBadgeViewTests.xctest */, 113 | ); 114 | name = Products; 115 | sourceTree = ""; 116 | }; 117 | E49E17F91AC8F5F3008C3009 /* PPDragDropBadgeView */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | E49E182A1AC8F818008C3009 /* PPDragDropBadgeView */, 121 | E49E17FE1AC8F5F3008C3009 /* AppDelegate.h */, 122 | E49E17FF1AC8F5F3008C3009 /* AppDelegate.m */, 123 | E4CD20AD1BE1B2CF001401E6 /* MenuViewController.h */, 124 | E4CD20AE1BE1B2CF001401E6 /* MenuViewController.m */, 125 | E4CD20AF1BE1B2CF001401E6 /* MenuViewController.xib */, 126 | E4CD20B21BE1B447001401E6 /* SimpleViewController.h */, 127 | E4CD20B31BE1B447001401E6 /* SimpleViewController.m */, 128 | E4CD20B41BE1B447001401E6 /* SimpleViewController.xib */, 129 | E4CD20B71BE1B68E001401E6 /* NavigationBarViewController.h */, 130 | E4CD20B81BE1B68E001401E6 /* NavigationBarViewController.m */, 131 | E4CD20B91BE1B68E001401E6 /* NavigationBarViewController.xib */, 132 | E4CD20BC1BE1BA8B001401E6 /* TabbarViewController.h */, 133 | E4CD20BD1BE1BA8B001401E6 /* TabbarViewController.m */, 134 | E4CD20BE1BE1BA8B001401E6 /* TabbarViewController.xib */, 135 | E4CD20A81BE12A0B001401E6 /* TableViewCell.h */, 136 | E4CD20A91BE12A0B001401E6 /* TableViewCell.m */, 137 | E4CD20AA1BE12A0B001401E6 /* TableViewCell.xib */, 138 | E44A2D891B0D97ED00C0A7D6 /* DemoTableViewController.h */, 139 | E44A2D8A1B0D97ED00C0A7D6 /* DemoTableViewController.m */, 140 | E44A2D8B1B0D97ED00C0A7D6 /* DemoTableViewController.xib */, 141 | E49E18071AC8F5F3008C3009 /* Images.xcassets */, 142 | E49E18091AC8F5F3008C3009 /* LaunchScreen.xib */, 143 | E49E17FA1AC8F5F3008C3009 /* Supporting Files */, 144 | ); 145 | path = PPDragDropBadgeView; 146 | sourceTree = ""; 147 | }; 148 | E49E17FA1AC8F5F3008C3009 /* Supporting Files */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | E49E17FB1AC8F5F3008C3009 /* Info.plist */, 152 | E49E17FC1AC8F5F3008C3009 /* main.m */, 153 | ); 154 | name = "Supporting Files"; 155 | sourceTree = ""; 156 | }; 157 | E49E18131AC8F5F3008C3009 /* PPDragDropBadgeViewTests */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | E49E18161AC8F5F3008C3009 /* PPDragDropBadgeViewTests.m */, 161 | E49E18141AC8F5F3008C3009 /* Supporting Files */, 162 | ); 163 | path = PPDragDropBadgeViewTests; 164 | sourceTree = ""; 165 | }; 166 | E49E18141AC8F5F3008C3009 /* Supporting Files */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | E49E18151AC8F5F3008C3009 /* Info.plist */, 170 | ); 171 | name = "Supporting Files"; 172 | sourceTree = ""; 173 | }; 174 | E49E182A1AC8F818008C3009 /* PPDragDropBadgeView */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | E49E182B1AC8F818008C3009 /* PPDragDropBadgeView.bundle */, 178 | E49E182C1AC8F818008C3009 /* PPDragDropBadgeView.h */, 179 | E49E182D1AC8F818008C3009 /* PPDragDropBadgeView.m */, 180 | E49E182E1AC8F818008C3009 /* PRTween */, 181 | ); 182 | path = PPDragDropBadgeView; 183 | sourceTree = ""; 184 | }; 185 | E49E182E1AC8F818008C3009 /* PRTween */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | E49E182F1AC8F818008C3009 /* PRTween.h */, 189 | E49E18301AC8F818008C3009 /* PRTween.m */, 190 | E49E18311AC8F818008C3009 /* PRTweenTimingFunctions.h */, 191 | E49E18321AC8F818008C3009 /* PRTweenTimingFunctions.m */, 192 | ); 193 | path = PRTween; 194 | sourceTree = ""; 195 | }; 196 | /* End PBXGroup section */ 197 | 198 | /* Begin PBXNativeTarget section */ 199 | E49E17F61AC8F5F3008C3009 /* PPDragDropBadgeView */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = E49E181A1AC8F5F3008C3009 /* Build configuration list for PBXNativeTarget "PPDragDropBadgeView" */; 202 | buildPhases = ( 203 | E49E17F31AC8F5F3008C3009 /* Sources */, 204 | E49E17F41AC8F5F3008C3009 /* Frameworks */, 205 | E49E17F51AC8F5F3008C3009 /* Resources */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | ); 211 | name = PPDragDropBadgeView; 212 | productName = PPDragDropBadgeView; 213 | productReference = E49E17F71AC8F5F3008C3009 /* PPDragDropBadgeView.app */; 214 | productType = "com.apple.product-type.application"; 215 | }; 216 | E49E180F1AC8F5F3008C3009 /* PPDragDropBadgeViewTests */ = { 217 | isa = PBXNativeTarget; 218 | buildConfigurationList = E49E181D1AC8F5F3008C3009 /* Build configuration list for PBXNativeTarget "PPDragDropBadgeViewTests" */; 219 | buildPhases = ( 220 | E49E180C1AC8F5F3008C3009 /* Sources */, 221 | E49E180D1AC8F5F3008C3009 /* Frameworks */, 222 | E49E180E1AC8F5F3008C3009 /* Resources */, 223 | ); 224 | buildRules = ( 225 | ); 226 | dependencies = ( 227 | E49E18121AC8F5F3008C3009 /* PBXTargetDependency */, 228 | ); 229 | name = PPDragDropBadgeViewTests; 230 | productName = PPDragDropBadgeViewTests; 231 | productReference = E49E18101AC8F5F3008C3009 /* PPDragDropBadgeViewTests.xctest */; 232 | productType = "com.apple.product-type.bundle.unit-test"; 233 | }; 234 | /* End PBXNativeTarget section */ 235 | 236 | /* Begin PBXProject section */ 237 | E49E17EF1AC8F5F3008C3009 /* Project object */ = { 238 | isa = PBXProject; 239 | attributes = { 240 | LastUpgradeCheck = 0610; 241 | ORGANIZATIONNAME = StarNet; 242 | TargetAttributes = { 243 | E49E17F61AC8F5F3008C3009 = { 244 | CreatedOnToolsVersion = 6.1.1; 245 | }; 246 | E49E180F1AC8F5F3008C3009 = { 247 | CreatedOnToolsVersion = 6.1.1; 248 | TestTargetID = E49E17F61AC8F5F3008C3009; 249 | }; 250 | }; 251 | }; 252 | buildConfigurationList = E49E17F21AC8F5F3008C3009 /* Build configuration list for PBXProject "PPDragDropBadgeView" */; 253 | compatibilityVersion = "Xcode 3.2"; 254 | developmentRegion = English; 255 | hasScannedForEncodings = 0; 256 | knownRegions = ( 257 | en, 258 | Base, 259 | ); 260 | mainGroup = E49E17EE1AC8F5F3008C3009; 261 | productRefGroup = E49E17F81AC8F5F3008C3009 /* Products */; 262 | projectDirPath = ""; 263 | projectRoot = ""; 264 | targets = ( 265 | E49E17F61AC8F5F3008C3009 /* PPDragDropBadgeView */, 266 | E49E180F1AC8F5F3008C3009 /* PPDragDropBadgeViewTests */, 267 | ); 268 | }; 269 | /* End PBXProject section */ 270 | 271 | /* Begin PBXResourcesBuildPhase section */ 272 | E49E17F51AC8F5F3008C3009 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | E49E180B1AC8F5F3008C3009 /* LaunchScreen.xib in Resources */, 277 | E4CD20AC1BE12A0B001401E6 /* TableViewCell.xib in Resources */, 278 | E49E18081AC8F5F3008C3009 /* Images.xcassets in Resources */, 279 | E4CD20B61BE1B447001401E6 /* SimpleViewController.xib in Resources */, 280 | E4CD20C01BE1BA8B001401E6 /* TabbarViewController.xib in Resources */, 281 | E4CD20BB1BE1B68E001401E6 /* NavigationBarViewController.xib in Resources */, 282 | E44A2D8D1B0D97ED00C0A7D6 /* DemoTableViewController.xib in Resources */, 283 | E49E18331AC8F818008C3009 /* PPDragDropBadgeView.bundle in Resources */, 284 | E4CD20B11BE1B2CF001401E6 /* MenuViewController.xib in Resources */, 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | E49E180E1AC8F5F3008C3009 /* Resources */ = { 289 | isa = PBXResourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXResourcesBuildPhase section */ 296 | 297 | /* Begin PBXSourcesBuildPhase section */ 298 | E49E17F31AC8F5F3008C3009 /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | E49E18351AC8F818008C3009 /* PRTween.m in Sources */, 303 | E4CD20BF1BE1BA8B001401E6 /* TabbarViewController.m in Sources */, 304 | E4CD20B51BE1B447001401E6 /* SimpleViewController.m in Sources */, 305 | E4CD20B01BE1B2CF001401E6 /* MenuViewController.m in Sources */, 306 | E49E18361AC8F818008C3009 /* PRTweenTimingFunctions.m in Sources */, 307 | E4CD20BA1BE1B68E001401E6 /* NavigationBarViewController.m in Sources */, 308 | E49E18341AC8F818008C3009 /* PPDragDropBadgeView.m in Sources */, 309 | E44A2D8C1B0D97ED00C0A7D6 /* DemoTableViewController.m in Sources */, 310 | E49E18001AC8F5F3008C3009 /* AppDelegate.m in Sources */, 311 | E4CD20AB1BE12A0B001401E6 /* TableViewCell.m in Sources */, 312 | E49E17FD1AC8F5F3008C3009 /* main.m in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | E49E180C1AC8F5F3008C3009 /* Sources */ = { 317 | isa = PBXSourcesBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | E49E18171AC8F5F3008C3009 /* PPDragDropBadgeViewTests.m in Sources */, 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | }; 324 | /* End PBXSourcesBuildPhase section */ 325 | 326 | /* Begin PBXTargetDependency section */ 327 | E49E18121AC8F5F3008C3009 /* PBXTargetDependency */ = { 328 | isa = PBXTargetDependency; 329 | target = E49E17F61AC8F5F3008C3009 /* PPDragDropBadgeView */; 330 | targetProxy = E49E18111AC8F5F3008C3009 /* PBXContainerItemProxy */; 331 | }; 332 | /* End PBXTargetDependency section */ 333 | 334 | /* Begin PBXVariantGroup section */ 335 | E49E18091AC8F5F3008C3009 /* LaunchScreen.xib */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | E49E180A1AC8F5F3008C3009 /* Base */, 339 | ); 340 | name = LaunchScreen.xib; 341 | sourceTree = ""; 342 | }; 343 | /* End PBXVariantGroup section */ 344 | 345 | /* Begin XCBuildConfiguration section */ 346 | E49E18181AC8F5F3008C3009 /* Debug */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 351 | CLANG_CXX_LIBRARY = "libc++"; 352 | CLANG_ENABLE_MODULES = YES; 353 | CLANG_ENABLE_OBJC_ARC = YES; 354 | CLANG_WARN_BOOL_CONVERSION = YES; 355 | CLANG_WARN_CONSTANT_CONVERSION = YES; 356 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 357 | CLANG_WARN_EMPTY_BODY = YES; 358 | CLANG_WARN_ENUM_CONVERSION = YES; 359 | CLANG_WARN_INT_CONVERSION = YES; 360 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 361 | CLANG_WARN_UNREACHABLE_CODE = YES; 362 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 363 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 364 | COPY_PHASE_STRIP = NO; 365 | ENABLE_STRICT_OBJC_MSGSEND = YES; 366 | GCC_C_LANGUAGE_STANDARD = gnu99; 367 | GCC_DYNAMIC_NO_PIC = NO; 368 | GCC_OPTIMIZATION_LEVEL = 0; 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 374 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 375 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 376 | GCC_WARN_UNDECLARED_SELECTOR = YES; 377 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 378 | GCC_WARN_UNUSED_FUNCTION = YES; 379 | GCC_WARN_UNUSED_VARIABLE = YES; 380 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 381 | MTL_ENABLE_DEBUG_INFO = YES; 382 | ONLY_ACTIVE_ARCH = YES; 383 | SDKROOT = iphoneos; 384 | TARGETED_DEVICE_FAMILY = "1,2"; 385 | }; 386 | name = Debug; 387 | }; 388 | E49E18191AC8F5F3008C3009 /* Release */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 393 | CLANG_CXX_LIBRARY = "libc++"; 394 | CLANG_ENABLE_MODULES = YES; 395 | CLANG_ENABLE_OBJC_ARC = YES; 396 | CLANG_WARN_BOOL_CONVERSION = YES; 397 | CLANG_WARN_CONSTANT_CONVERSION = YES; 398 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 399 | CLANG_WARN_EMPTY_BODY = YES; 400 | CLANG_WARN_ENUM_CONVERSION = YES; 401 | CLANG_WARN_INT_CONVERSION = YES; 402 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 403 | CLANG_WARN_UNREACHABLE_CODE = YES; 404 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 405 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 406 | COPY_PHASE_STRIP = YES; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu99; 410 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 411 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 412 | GCC_WARN_UNDECLARED_SELECTOR = YES; 413 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 414 | GCC_WARN_UNUSED_FUNCTION = YES; 415 | GCC_WARN_UNUSED_VARIABLE = YES; 416 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 417 | MTL_ENABLE_DEBUG_INFO = NO; 418 | SDKROOT = iphoneos; 419 | TARGETED_DEVICE_FAMILY = "1,2"; 420 | VALIDATE_PRODUCT = YES; 421 | }; 422 | name = Release; 423 | }; 424 | E49E181B1AC8F5F3008C3009 /* Debug */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 428 | INFOPLIST_FILE = PPDragDropBadgeView/Info.plist; 429 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 430 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | }; 433 | name = Debug; 434 | }; 435 | E49E181C1AC8F5F3008C3009 /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | buildSettings = { 438 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 439 | INFOPLIST_FILE = PPDragDropBadgeView/Info.plist; 440 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 441 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | }; 444 | name = Release; 445 | }; 446 | E49E181E1AC8F5F3008C3009 /* Debug */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | BUNDLE_LOADER = "$(TEST_HOST)"; 450 | FRAMEWORK_SEARCH_PATHS = ( 451 | "$(SDKROOT)/Developer/Library/Frameworks", 452 | "$(inherited)", 453 | ); 454 | GCC_PREPROCESSOR_DEFINITIONS = ( 455 | "DEBUG=1", 456 | "$(inherited)", 457 | ); 458 | INFOPLIST_FILE = PPDragDropBadgeViewTests/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PPDragDropBadgeView.app/PPDragDropBadgeView"; 462 | }; 463 | name = Debug; 464 | }; 465 | E49E181F1AC8F5F3008C3009 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | BUNDLE_LOADER = "$(TEST_HOST)"; 469 | FRAMEWORK_SEARCH_PATHS = ( 470 | "$(SDKROOT)/Developer/Library/Frameworks", 471 | "$(inherited)", 472 | ); 473 | INFOPLIST_FILE = PPDragDropBadgeViewTests/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PPDragDropBadgeView.app/PPDragDropBadgeView"; 477 | }; 478 | name = Release; 479 | }; 480 | /* End XCBuildConfiguration section */ 481 | 482 | /* Begin XCConfigurationList section */ 483 | E49E17F21AC8F5F3008C3009 /* Build configuration list for PBXProject "PPDragDropBadgeView" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | E49E18181AC8F5F3008C3009 /* Debug */, 487 | E49E18191AC8F5F3008C3009 /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | E49E181A1AC8F5F3008C3009 /* Build configuration list for PBXNativeTarget "PPDragDropBadgeView" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | E49E181B1AC8F5F3008C3009 /* Debug */, 496 | E49E181C1AC8F5F3008C3009 /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | E49E181D1AC8F5F3008C3009 /* Build configuration list for PBXNativeTarget "PPDragDropBadgeViewTests" */ = { 502 | isa = XCConfigurationList; 503 | buildConfigurations = ( 504 | E49E181E1AC8F5F3008C3009 /* Debug */, 505 | E49E181F1AC8F5F3008C3009 /* Release */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | /* End XCConfigurationList section */ 511 | }; 512 | rootObject = E49E17EF1AC8F5F3008C3009 /* Project object */; 513 | } 514 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.xcodeproj/project.xcworkspace/xcshareddata/PPDragDropBadgeView.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 0ED55EB1-E79F-45A8-8B29-DD35DC970EDB 9 | IDESourceControlProjectName 10 | PPDragDropBadgeView 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | AE94FBEE27462942413766EDC7156A99A7C5A5AF 14 | https://github.com/smallmuou/PPDragDropBadgeView.git 15 | 16 | IDESourceControlProjectPath 17 | PPDragDropBadgeView.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | AE94FBEE27462942413766EDC7156A99A7C5A5AF 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/smallmuou/PPDragDropBadgeView.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | AE94FBEE27462942413766EDC7156A99A7C5A5AF 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | AE94FBEE27462942413766EDC7156A99A7C5A5AF 36 | IDESourceControlWCCName 37 | PPDragDropBadgeView 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.xcodeproj/xcuserdata/starnet.xcuserdatad/xcschemes/PPDragDropBadgeView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /PPDragDropBadgeView.xcodeproj/xcuserdata/starnet.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PPDragDropBadgeView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E49E17F61AC8F5F3008C3009 16 | 17 | primary 18 | 19 | 20 | E49E180F1AC8F5F3008C3009 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 3/30/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 3/30/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MenuViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | 22 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 23 | 24 | MenuViewController* dvc = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil]; 25 | UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:dvc]; 26 | self.window.rootViewController = nav; 27 | [self.window makeKeyAndVisible]; 28 | 29 | return YES; 30 | } 31 | 32 | - (void)applicationWillResignActive:(UIApplication *)application { 33 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 34 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 35 | } 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | } 41 | 42 | - (void)applicationWillEnterForeground:(UIApplication *)application { 43 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 44 | } 45 | 46 | - (void)applicationDidBecomeActive:(UIApplication *)application { 47 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 48 | } 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /PPDragDropBadgeView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.evideo.weiju 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/MenuViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuViewController.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MenuViewController : UITableViewController 12 | 13 | @property (nonatomic, strong) NSArray* tableData; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/MenuViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuViewController.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "MenuViewController.h" 10 | #import "SimpleViewController.h" 11 | #import "NavigationBarViewController.h" 12 | #import "TabbarViewController.h" 13 | #import "DemoTableViewController.h" 14 | 15 | @interface MenuViewController () 16 | 17 | 18 | @end 19 | 20 | @implementation MenuViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | self.title = @"PPDragDropBadgeView"; 26 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"identifier"]; 27 | 28 | __weak typeof(self) weakSelf = self; 29 | self.tableData = @[ 30 | @{ 31 | @"title":@"Simple", 32 | @"action":^{ 33 | SimpleViewController* vc = [[SimpleViewController alloc] initWithNibName:@"SimpleViewController" bundle:nil]; 34 | vc.title = @"Simple"; 35 | [weakSelf.navigationController pushViewController:vc animated:YES]; 36 | } 37 | }, 38 | @{ 39 | @"title":@"NavigationBar", 40 | @"action":^{ 41 | NavigationBarViewController* vc = [[NavigationBarViewController alloc] initWithNibName:@"NavigationBarViewController" bundle:nil]; 42 | vc.title = @"NavigationBar"; 43 | [weakSelf.navigationController pushViewController:vc animated:YES]; 44 | } 45 | }, 46 | @{ 47 | @"title":@"Tabbar", 48 | @"action":^{ 49 | TabbarViewController* vc = [[TabbarViewController alloc] initWithNibName:@"TabbarViewController" bundle:nil]; 50 | vc.title = @"Tabbar"; 51 | [weakSelf.navigationController pushViewController:vc animated:YES]; 52 | } 53 | }, 54 | @{ 55 | @"title":@"TableView", 56 | @"action":^{ 57 | DemoTableViewController* vc = [[DemoTableViewController alloc] initWithNibName:@"DemoTableViewController" bundle:nil]; 58 | vc.title = @"TableView"; 59 | [weakSelf.navigationController pushViewController:vc animated:YES]; 60 | } 61 | }, 62 | ]; 63 | } 64 | 65 | - (void)didReceiveMemoryWarning { 66 | [super didReceiveMemoryWarning]; 67 | // Dispose of any resources that can be recreated. 68 | } 69 | 70 | #pragma mark - Table view data source 71 | 72 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 73 | return 1; 74 | } 75 | 76 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 77 | return [self.tableData count]; 78 | } 79 | 80 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 81 | UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"]; 82 | 83 | NSDictionary* info = self.tableData[indexPath.row]; 84 | cell.textLabel.text = info[@"title"]; 85 | 86 | return cell; 87 | } 88 | 89 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 90 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 91 | NSDictionary* info = self.tableData[indexPath.row]; 92 | ((void(^)())info[@"action"])(); 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/MenuViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/NavigationBarViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarViewController.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NavigationBarViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/NavigationBarViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarViewController.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "NavigationBarViewController.h" 10 | #import "PPDragDropBadgeView.h" 11 | 12 | @interface NavigationBarViewController () 13 | @end 14 | 15 | @implementation NavigationBarViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view from its nib. 20 | { 21 | PPDragDropBadgeView* badge = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(10, 10, 25, 25)]; 22 | badge.text = @"8"; 23 | 24 | UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; 25 | container.backgroundColor = [UIColor clearColor]; 26 | [container addSubview:badge]; 27 | 28 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:container]; 29 | } 30 | } 31 | 32 | - (void)didReceiveMemoryWarning { 33 | [super didReceiveMemoryWarning]; 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | /* 38 | #pragma mark - Navigation 39 | 40 | // In a storyboard-based application, you will often want to do a little preparation before navigation 41 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 42 | // Get the new view controller using [segue destinationViewController]. 43 | // Pass the selected object to the new view controller. 44 | } 45 | */ 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/NavigationBarViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb0@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb0@2x.png -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb1@2x.png -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb2@2x.png -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb3@2x.png -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallmuou/PPDragDropBadgeView/0bd8e0b542cfb7e6c5d7b4dd8c1d9c02c81e9e9a/PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.bundle/bomb4@2x.png -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PPDragDropBadgeView.h 3 | * 4 | * A badge view with drag and drop. 5 | * 6 | * MIT licence follows: 7 | * 8 | * Copyright (C) 2015 Wenva 9 | 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is furnished 15 | * to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | #import 30 | 31 | /** 32 | * A badge view support drag and drop. 33 | * 34 | * @Note please use addSubview to add PPDragDropBadgeView. 35 | * currently, not support like tableViewCell.accessoryView = badge or [[UIBarButtonItem alloc] initWithCustomView:badge]. 36 | */ 37 | @interface PPDragDropBadgeView : UIView 38 | 39 | /** return the version of PPDragDropBadgeView */ 40 | + (NSString* )version; 41 | 42 | /** 43 | * init badge view 44 | * 45 | * @param frame The frame rect 46 | * @param dragdropCompletion The completion block when drag drop done. 47 | */ 48 | - (instancetype)initWithFrame:(CGRect)frame 49 | dragdropCompletion:(void(^)())dragdropCompletion; 50 | 51 | /** The completion block when drag drop done. */ 52 | @property (nonatomic, copy) void(^dragdropCompletion)(); 53 | 54 | /** The tint color of badge view. Default is red */ 55 | @property (nonatomic, strong) UIColor* tintColor; 56 | 57 | /** Hide the badge view when text is zero. Default is YES */ 58 | @property (nonatomic, assign) BOOL hiddenWhenZero; 59 | 60 | /** The font of text, Default System font 16.0f */ 61 | @property (nonatomic, strong) UIFont* font; 62 | 63 | /** The font size of text, Default System font 16.0f */ 64 | @property (nonatomic, assign) CGFloat fontSize; 65 | 66 | /** Auto fit font size, Default is NO */ 67 | @property (nonatomic, assign) BOOL fontSizeAutoFit; 68 | 69 | /** The text of badge view. */ 70 | @property (nonatomic, strong) NSString* text; 71 | 72 | /** The text color of badge view. */ 73 | @property (nonatomic, strong) UIColor* textColor; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PPDragDropBadgeView.m: -------------------------------------------------------------------------------- 1 | /** 2 | * PPDragDropBadgeView.c 3 | * 4 | * A badge view with drag and drop. 5 | * 6 | * MIT licence follows: 7 | * 8 | * Copyright (C) 2015 Wenva 9 | 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is furnished 15 | * to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | #import "PPDragDropBadgeView.h" 30 | #import "PRTween.h" 31 | #import "PRTweenTimingFunctions.h" 32 | 33 | #define kDefaultTintColor [UIColor redColor] 34 | #define kDefaultBorderColor [UIColor clearColor] 35 | #define kDefaultBorderWidth 1.0f 36 | #define kElasticDuration 0.5f 37 | #define kFromRadiusScaleCoefficient 0.09f 38 | #define kToRadiusScaleCoefficient 0.05f 39 | #define kMaxDistanceScaleCoefficient 8.0f 40 | #define kFollowTimeInterval 0.016f 41 | #define kBombDuration 0.5f 42 | #define kValidRadius 20.0f 43 | #define kDefaultFontSize 16.0f 44 | 45 | #define kPaddingSize 10.0f 46 | 47 | CGFloat distanceBetweenPoints (CGPoint p1, CGPoint p2) { 48 | CGFloat deltaX = p2.x - p1.x; 49 | CGFloat deltaY = p2.y - p1.y; 50 | return sqrt(deltaX*deltaX + deltaY*deltaY); 51 | }; 52 | 53 | @interface PPDragDropBadgeView () { 54 | UIControl* _overlayView; //拖动时self依附的view 55 | UIView* _originSuperView; //原self容器 56 | CGFloat _viscosity; //粘度 57 | CGSize _size; //圆大小 58 | CGPoint _originPoint; //源点 59 | CGFloat _radius; //圆半径 60 | BOOL _padding; //配置内边距 61 | 62 | CGPoint _fromPoint; 63 | CGPoint _toPoint; 64 | CGFloat _fromRadius; 65 | CGFloat _toRadius; 66 | 67 | CGPoint _elasticBeginPoint; 68 | 69 | BOOL _missed; 70 | BOOL _beEnableDragDrop; 71 | CGFloat _maxDistance; 72 | CGFloat _distance; 73 | PRTweenOperation* _activeTweenOperation; 74 | 75 | UILabel* _textLabel; 76 | UIImageView* _bombImageView; 77 | 78 | CAShapeLayer* _shapeLayer; 79 | 80 | UIPanGestureRecognizer* _panGestureRecognizer; 81 | } 82 | 83 | @property (nonatomic, strong) UIControl* overlayView; 84 | 85 | @end 86 | 87 | @implementation PPDragDropBadgeView 88 | 89 | + (NSString* )version { 90 | return @"2.1"; 91 | } 92 | 93 | - (void)awakeFromNib { 94 | _padding = YES; 95 | [self setup]; 96 | } 97 | 98 | - (instancetype)initWithFrame:(CGRect)frame { 99 | return [self initWithFrame:frame dragdropCompletion:nil]; 100 | } 101 | 102 | - (instancetype)initWithFrame:(CGRect)frame 103 | dragdropCompletion:(void(^)())dragdropCompletion { 104 | self = [super initWithFrame:frame]; 105 | if (self) { 106 | self.dragdropCompletion = dragdropCompletion; 107 | [self setup]; 108 | } 109 | return self; 110 | } 111 | 112 | - (void)setup { 113 | //为了便于拖拽,扩大空间区域 114 | _size = self.frame.size; 115 | 116 | if (!_padding) { 117 | CGRect wapperFrame = self.frame; 118 | wapperFrame.origin.x -= kPaddingSize; 119 | wapperFrame.origin.y -= kPaddingSize; 120 | wapperFrame.size.width += kPaddingSize*2; 121 | wapperFrame.size.height += kPaddingSize*2; 122 | self.frame = wapperFrame; 123 | _padding = YES; 124 | } 125 | 126 | self.backgroundColor = [UIColor clearColor]; 127 | 128 | _tintColor = kDefaultTintColor; 129 | _hiddenWhenZero = YES; 130 | _fontSizeAutoFit = NO; 131 | 132 | _shapeLayer = [CAShapeLayer new]; 133 | [self.layer addSublayer:_shapeLayer]; 134 | _shapeLayer.frame = CGRectMake(0, 0, _size.width, _size.height); 135 | _shapeLayer.fillColor = _tintColor.CGColor; 136 | 137 | _radius = _size.width/2; 138 | _originPoint = CGPointMake(kPaddingSize+_radius, kPaddingSize+_radius); 139 | 140 | //爆炸效果 141 | _bombImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 34, 34)]; 142 | _bombImageView.animationImages = @[[UIImage imageNamed:@"PPDragDropBadgeView.bundle/bomb0"], 143 | [UIImage imageNamed:@"PPDragDropBadgeView.bundle/bomb1"], 144 | [UIImage imageNamed:@"PPDragDropBadgeView.bundle/bomb2"], 145 | [UIImage imageNamed:@"PPDragDropBadgeView.bundle/bomb3"], 146 | [UIImage imageNamed:@"PPDragDropBadgeView.bundle/bomb4"]]; 147 | _bombImageView.animationRepeatCount = 1; 148 | _bombImageView.animationDuration = kBombDuration; 149 | [self addSubview:_bombImageView]; 150 | 151 | //文字 152 | _textLabel = [[UILabel alloc] initWithFrame:CGRectMake(kPaddingSize, kPaddingSize, _size.width, _size.width)]; 153 | _textLabel.textColor = [UIColor whiteColor]; 154 | _textLabel.font = [UIFont systemFontOfSize:kDefaultFontSize]; 155 | _textLabel.textAlignment = NSTextAlignmentCenter; 156 | _textLabel.text = @""; 157 | [self addSubview:_textLabel]; 158 | 159 | //拖动手势 160 | _panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onGestureAction:)]; 161 | [_panGestureRecognizer setDelaysTouchesBegan:YES]; 162 | [_panGestureRecognizer setDelaysTouchesEnded:YES]; 163 | [self addGestureRecognizer:_panGestureRecognizer]; 164 | } 165 | 166 | - (void)layoutSubviews { 167 | [super layoutSubviews]; 168 | 169 | [self reset]; 170 | } 171 | 172 | - (void)dealloc { 173 | [self removeGestureRecognizer:_panGestureRecognizer]; 174 | } 175 | 176 | - (void)setTintColor:(UIColor *)tintColor { 177 | _tintColor = tintColor?tintColor:kDefaultTintColor; 178 | _shapeLayer.fillColor = _tintColor.CGColor; 179 | } 180 | 181 | - (void)setFont:(UIFont *)font { 182 | [_textLabel setFont:font]; 183 | } 184 | 185 | - (void)setFontSize:(CGFloat)fontSize { 186 | [_textLabel setFont:[_textLabel.font fontWithSize:fontSize]]; 187 | } 188 | 189 | - (void)setText:(NSString *)text { 190 | _textLabel.text = text; 191 | _textLabel.hidden = NO; 192 | 193 | self.hidden = NO; 194 | if (_hiddenWhenZero 195 | && ([text isEqualToString:@"0"] || [text isEqualToString:@""])) { 196 | self.hidden = YES; 197 | } 198 | 199 | [self reset]; 200 | } 201 | 202 | - (void)setTextColor:(UIColor *)textColor { 203 | _textLabel.textColor = textColor; 204 | } 205 | 206 | - (void)reset { 207 | _fromPoint = _originPoint; 208 | _toPoint = _fromPoint; 209 | _maxDistance = kMaxDistanceScaleCoefficient*_radius; 210 | _beEnableDragDrop = YES; 211 | 212 | [self updateRadius]; 213 | } 214 | 215 | - (void)update:(PRTweenPeriod*)period { 216 | CGFloat c = period.tweenedValue; 217 | if (isnan(c) || c > 10000000.0f || c < -10000000.0f) return; 218 | 219 | if (_missed) { 220 | CGFloat x = (_distance != 0)?((_toPoint.x-_elasticBeginPoint.x)*c/_distance):0; 221 | CGFloat y = (_distance != 0)?((_toPoint.y-_elasticBeginPoint.y)*c/_distance):0; 222 | 223 | _fromPoint = CGPointMake(_elasticBeginPoint.x+x, _elasticBeginPoint.y+y); 224 | } else { 225 | CGFloat x = (_distance != 0)?((_fromPoint.x - _elasticBeginPoint.x)*c/_distance):0; 226 | CGFloat y = (_distance != 0)?((_fromPoint.y - _elasticBeginPoint.y)*c/_distance):0; 227 | 228 | _toPoint = CGPointMake(_elasticBeginPoint.x+x, _elasticBeginPoint.y+y); 229 | } 230 | 231 | [self updateRadius]; 232 | } 233 | 234 | 235 | - (void)updateRadius { 236 | CGFloat r = distanceBetweenPoints(_fromPoint, _toPoint); 237 | 238 | _fromRadius = _radius-kFromRadiusScaleCoefficient*r; 239 | _toRadius = _radius-kToRadiusScaleCoefficient*r; 240 | _viscosity = (_maxDistance != 0)?(1.0-r/_maxDistance):1.0f; 241 | 242 | if (_fontSizeAutoFit) { 243 | _textLabel.font = [_textLabel.font fontWithSize:(_textLabel.text.length)?((2*_toRadius)/(1.2*_textLabel.text.length)):kDefaultFontSize]; 244 | } 245 | _textLabel.center = _toPoint; 246 | 247 | [self setNeedsDisplay]; 248 | } 249 | 250 | 251 | - (UIBezierPath* )bezierPathWithFromPoint:(CGPoint)fromPoint 252 | toPoint:(CGPoint)toPoint 253 | fromRadius:(CGFloat)fromRadius 254 | toRadius:(CGFloat)toRadius scale:(CGFloat)scale{ 255 | 256 | if (isnan(fromRadius) || isnan(toRadius)||isnan(fromRadius)||isnan(toRadius)) return nil; 257 | 258 | UIBezierPath* path = [[UIBezierPath alloc] init]; 259 | CGFloat r = distanceBetweenPoints(fromPoint, toPoint); 260 | CGFloat offsetY = fabs(fromRadius-toRadius); 261 | if (r <= offsetY) { 262 | CGPoint center; 263 | CGFloat radius; 264 | if (fromRadius >= toRadius) { 265 | center = fromPoint; 266 | radius = fromRadius; 267 | } else { 268 | center = toPoint; 269 | radius = toRadius; 270 | } 271 | [path addArcWithCenter:center radius:radius startAngle:0 endAngle:2*M_PI clockwise:YES]; 272 | } else { 273 | CGFloat originX = toPoint.x - fromPoint.x; 274 | CGFloat originY = toPoint.y - fromPoint.y; 275 | 276 | CGFloat fromOriginAngel = (originX >= 0)?atan(originY/originX):(atan(originY/originX)+M_PI); 277 | CGFloat fromOffsetAngel = (fromRadius >= toRadius)?acos(offsetY/r):(M_PI-acos(offsetY/r)); 278 | CGFloat fromStartAngel = fromOriginAngel + fromOffsetAngel; 279 | CGFloat fromEndAngel = fromOriginAngel - fromOffsetAngel; 280 | 281 | CGPoint fromStartPoint = CGPointMake(fromPoint.x+cos(fromStartAngel)*fromRadius, fromPoint.y+sin(fromStartAngel)*fromRadius); 282 | 283 | CGFloat toOriginAngel = (originX < 0)?atan(originY/originX):(atan(originY/originX)+M_PI); 284 | CGFloat toOffsetAngel = (fromRadius < toRadius)?acos(offsetY/r):(M_PI-acos(offsetY/r)); 285 | CGFloat toStartAngel = toOriginAngel + toOffsetAngel; 286 | CGFloat toEndAngel = toOriginAngel - toOffsetAngel; 287 | CGPoint toStartPoint = CGPointMake(toPoint.x+cos(toStartAngel)*toRadius, toPoint.y+sin(toStartAngel)*toRadius); 288 | 289 | CGPoint middlePoint = CGPointMake(fromPoint.x+(toPoint.x-fromPoint.x)/2, fromPoint.y+(toPoint.y-fromPoint.y)/2); 290 | CGFloat middleRadius = (fromRadius+toRadius)/2; 291 | 292 | CGPoint fromControlPoint = CGPointMake(middlePoint.x+sin(fromOriginAngel)*middleRadius*scale, middlePoint.y-cos(fromOriginAngel)*middleRadius*scale); 293 | 294 | CGPoint toControlPoint = CGPointMake(middlePoint.x+sin(toOriginAngel)*middleRadius*scale, middlePoint.y-cos(toOriginAngel)*middleRadius*scale); 295 | 296 | [path moveToPoint:fromStartPoint]; 297 | 298 | //绘制from弧形 299 | [path addArcWithCenter:fromPoint radius:fromRadius startAngle:fromStartAngel endAngle:fromEndAngel clockwise:YES]; 300 | 301 | //绘制from到to之间的贝塞尔曲线 302 | if (r > (fromRadius+toRadius)) { 303 | [path addQuadCurveToPoint:toStartPoint controlPoint:fromControlPoint]; 304 | } 305 | 306 | //绘制to弧形 307 | [path addArcWithCenter:toPoint radius:toRadius startAngle:toStartAngel endAngle:toEndAngel clockwise:YES]; 308 | 309 | //绘制to到from之间的贝塞尔曲线 310 | if (r > (fromRadius+toRadius)) { 311 | [path addQuadCurveToPoint:fromStartPoint controlPoint:toControlPoint]; 312 | } 313 | } 314 | 315 | [path closePath]; 316 | 317 | return path; 318 | } 319 | 320 | - (void)drawRect:(CGRect)rect { 321 | UIBezierPath* path = [self bezierPathWithFromPoint:_fromPoint toPoint:_toPoint fromRadius:_fromRadius toRadius:_toRadius scale:_viscosity]; 322 | _shapeLayer.path = path.CGPath; 323 | } 324 | 325 | #pragma mark - Touch 326 | - (void)onGestureAction:(UIPanGestureRecognizer* )gesture { 327 | if (!_beEnableDragDrop) return; 328 | 329 | CGPoint point = [gesture locationInView:self]; 330 | switch (gesture.state) { 331 | case UIGestureRecognizerStateBegan: { 332 | [self touchesBegan:point]; 333 | break; 334 | } 335 | case UIGestureRecognizerStateEnded: 336 | [self touchesEnded:point]; 337 | break; 338 | case UIGestureRecognizerStateChanged: 339 | [self touchesMoved:point]; 340 | break; 341 | default: 342 | break; 343 | } 344 | } 345 | 346 | - (void)touchesBegan:(CGPoint)point { 347 | _missed = NO; 348 | [self becomeUpper]; 349 | } 350 | 351 | - (UIControl *)overlayView { 352 | if(!_overlayView) { 353 | _overlayView = [[UIControl alloc] initWithFrame:[UIScreen mainScreen].bounds]; 354 | _overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 355 | _overlayView.backgroundColor = [UIColor clearColor]; 356 | } 357 | return _overlayView; 358 | } 359 | 360 | - (void)becomeUpper { 361 | if(!self.overlayView.superview){ 362 | NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator]; 363 | for (UIWindow *window in frontToBackWindows){ 364 | BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen; 365 | BOOL windowIsVisible = !window.hidden && window.alpha > 0; 366 | BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal; 367 | 368 | if (windowOnMainScreen && windowIsVisible && windowLevelNormal) { 369 | [window addSubview:self.overlayView]; 370 | break; 371 | } 372 | } 373 | } else { 374 | [self.overlayView.superview bringSubviewToFront:self.overlayView]; 375 | } 376 | 377 | _originSuperView = self.superview; 378 | self.center = [_originSuperView convertPoint:self.center toView:self.overlayView]; 379 | 380 | if ([_originSuperView isKindOfClass:[UITableViewCell class]] 381 | && self == ((UITableViewCell* )_originSuperView).accessoryView) { 382 | ((UITableViewCell* )_originSuperView).accessoryView = nil; 383 | } 384 | 385 | [self.overlayView addSubview:self]; 386 | } 387 | 388 | - (void)resignUpper { 389 | self.center = [_overlayView convertPoint:self.center toView:_originSuperView]; 390 | 391 | if ([_originSuperView isKindOfClass:[UITableViewCell class]] 392 | && self == ((UITableViewCell* )_originSuperView).accessoryView) { 393 | ((UITableViewCell* )_originSuperView).accessoryView = self; 394 | } else { 395 | [_originSuperView addSubview:self]; 396 | } 397 | 398 | [_overlayView removeFromSuperview]; 399 | _overlayView = nil; 400 | } 401 | 402 | - (void)touchesEnded:(CGPoint)point { 403 | if (!_missed) { 404 | _elasticBeginPoint = _toPoint; 405 | _distance = distanceBetweenPoints(_fromPoint, _toPoint); 406 | 407 | [[PRTween sharedInstance] removeTweenOperation:_activeTweenOperation]; 408 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:0 endValue:_distance duration:kElasticDuration]; 409 | _activeTweenOperation = [[PRTween sharedInstance] addTweenPeriod:period target:self selector:@selector(update:) timingFunction:&PRTweenTimingFunctionElasticOut]; 410 | 411 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kElasticDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 412 | [self resignUpper]; 413 | }); 414 | } else { 415 | if (CGRectContainsPoint(CGRectMake(_originPoint.x-kValidRadius, _originPoint.y-kValidRadius, 2*kValidRadius, 2*kValidRadius), point)) { 416 | [self resignUpper]; 417 | [self reset]; 418 | } else { 419 | _bombImageView.center = _toPoint; 420 | _toRadius = 0; 421 | _fromRadius = 0; 422 | _textLabel.hidden = YES; 423 | [_bombImageView startAnimating]; 424 | _beEnableDragDrop = NO; 425 | _activeTweenOperation.updateSelector = nil; 426 | [[PRTween sharedInstance] removeTweenOperation:_activeTweenOperation]; 427 | 428 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kBombDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 429 | [self resignUpper]; 430 | }); 431 | 432 | if (self.dragdropCompletion) { 433 | self.dragdropCompletion(); 434 | } 435 | } 436 | 437 | [self setNeedsDisplay]; 438 | } 439 | } 440 | 441 | - (void)touchesMoved:(CGPoint)point { 442 | CGFloat r = distanceBetweenPoints(_fromPoint, point); 443 | if (_missed) { 444 | _activeTweenOperation.updateSelector = nil; 445 | if (!CGPointEqualToPoint(point, CGPointZero)) { 446 | _fromPoint = _toPoint = point; 447 | [self updateRadius]; 448 | } 449 | } else { 450 | _toPoint = point; 451 | if (r > _maxDistance) { 452 | _missed = YES; 453 | _elasticBeginPoint = _fromPoint; 454 | _distance = distanceBetweenPoints(_fromPoint, _toPoint); 455 | 456 | [[PRTween sharedInstance] removeTweenOperation:_activeTweenOperation]; 457 | 458 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:0 endValue:_distance duration:kElasticDuration]; 459 | _activeTweenOperation = [[PRTween sharedInstance] addTweenPeriod:period target:self selector:@selector(update:) timingFunction:&PRTweenTimingFunctionElasticOut]; 460 | } else { 461 | [self updateRadius]; 462 | } 463 | } 464 | 465 | } 466 | 467 | @end 468 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PRTween/PRTween.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import 4 | 5 | #import "PRTweenTimingFunctions.h" 6 | 7 | typedef CGFloat(*PRTweenTimingFunction)(CGFloat, CGFloat, CGFloat, CGFloat); 8 | #if NS_BLOCKS_AVAILABLE 9 | @class PRTweenPeriod; 10 | typedef void (^PRTweenUpdateBlock)(PRTweenPeriod *period); 11 | typedef void (^PRTweenCompleteBlock)(); 12 | #endif 13 | 14 | @interface PRTweenPeriod : NSObject { 15 | CGFloat duration; 16 | CGFloat delay; 17 | CGFloat startOffset; 18 | CGFloat startValue; 19 | CGFloat endValue; 20 | CGFloat tweenedValue; 21 | } 22 | 23 | @property (nonatomic) CGFloat startValue; 24 | @property (nonatomic) CGFloat endValue; 25 | @property (nonatomic) CGFloat tweenedValue; 26 | @property (nonatomic) CGFloat duration; 27 | @property (nonatomic) CGFloat delay; 28 | @property (nonatomic) CGFloat startOffset; 29 | 30 | + (id)periodWithStartValue:(CGFloat)aStartValue endValue:(CGFloat)anEndValue duration:(CGFloat)duration; 31 | 32 | @end 33 | 34 | @protocol PRTweenLerpPeriod 35 | 36 | - (NSValue*)tweenedValueForProgress:(CGFloat)progress; 37 | - (void)setProgress:(CGFloat)progress; 38 | 39 | @end 40 | 41 | @interface PRTweenLerpPeriod : PRTweenPeriod { 42 | NSValue *startLerp; 43 | NSValue *endLerp; 44 | NSValue *tweenedLerp; 45 | } 46 | 47 | @property (nonatomic, copy) NSValue *startLerp; 48 | @property (nonatomic, copy) NSValue *endLerp; 49 | @property (nonatomic, copy) NSValue *tweenedLerp; 50 | 51 | + (id)periodWithStartValue:(NSValue*)aStartValue endValue:(NSValue*)anEndValue duration:(CGFloat)duration; 52 | 53 | @end 54 | 55 | @interface PRTweenCGPointLerpPeriod : PRTweenLerpPeriod 56 | + (id)periodWithStartCGPoint:(CGPoint)aStartPoint endCGPoint:(CGPoint)anEndPoint duration:(CGFloat)duration; 57 | - (CGPoint)startCGPoint; 58 | - (CGPoint)tweenedCGPoint; 59 | - (CGPoint)endCGPoint; 60 | @end 61 | 62 | @interface PRTweenCGRectLerpPeriod : PRTweenLerpPeriod 63 | + (id)periodWithStartCGRect:(CGRect)aStartRect endCGRect:(CGRect)anEndRect duration:(CGFloat)duration; 64 | - (CGRect)startCGRect; 65 | - (CGRect)tweenedCGRect; 66 | - (CGRect)endCGRect; 67 | @end 68 | 69 | @interface PRTweenOperation : NSObject { 70 | PRTweenPeriod *period; 71 | NSObject *target; 72 | SEL updateSelector; 73 | SEL completeSelector; 74 | PRTweenTimingFunction timingFunction; 75 | 76 | CGFloat *boundRef; 77 | SEL boundGetter; 78 | SEL boundSetter; 79 | 80 | BOOL override; 81 | 82 | #if NS_BLOCKS_AVAILABLE 83 | PRTweenUpdateBlock updateBlock; 84 | PRTweenCompleteBlock completeBlock; 85 | #endif 86 | 87 | @private 88 | BOOL canUseBuiltAnimation; 89 | } 90 | 91 | @property (nonatomic, retain) PRTweenPeriod *period; 92 | @property (nonatomic, retain) NSObject *target; 93 | @property (nonatomic) SEL updateSelector; 94 | @property (nonatomic) SEL completeSelector; 95 | @property (nonatomic, assign) PRTweenTimingFunction timingFunction; 96 | 97 | #if NS_BLOCKS_AVAILABLE 98 | @property (nonatomic, copy) PRTweenUpdateBlock updateBlock; 99 | @property (nonatomic, copy) PRTweenCompleteBlock completeBlock; 100 | #endif 101 | 102 | @property (nonatomic, assign) CGFloat *boundRef; 103 | @property (nonatomic, retain) id boundObject; 104 | @property (nonatomic) SEL boundGetter; 105 | @property (nonatomic) SEL boundSetter; 106 | @property (nonatomic) BOOL override; 107 | 108 | @end 109 | 110 | @interface PRTweenCGPointLerp : NSObject 111 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector; 112 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration delay:(CGFloat)delay timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector; 113 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration; 114 | #if NS_BLOCKS_AVAILABLE 115 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock; 116 | #endif 117 | @end 118 | 119 | @interface PRTweenCGRectLerp : NSObject 120 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector; 121 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration delay:(CGFloat)delay timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector; 122 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration; 123 | #if NS_BLOCKS_AVAILABLE 124 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock; 125 | #endif 126 | @end 127 | 128 | @interface PRTween : NSObject { 129 | NSMutableArray *tweenOperations; 130 | NSMutableArray *expiredTweenOperations; 131 | NSTimer *timer; 132 | CGFloat timeOffset; 133 | 134 | PRTweenTimingFunction defaultTimingFunction; 135 | BOOL useBuiltInAnimationsWhenPossible; 136 | } 137 | 138 | @property (nonatomic, readonly) CGFloat timeOffset; 139 | @property (nonatomic, assign) PRTweenTimingFunction defaultTimingFunction; 140 | @property (nonatomic, assign) BOOL useBuiltInAnimationsWhenPossible; 141 | 142 | + (PRTween *)sharedInstance; 143 | 144 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector; 145 | 146 | + (PRTweenOperation *)tween:(CGFloat*)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector; 147 | 148 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration; 149 | 150 | + (PRTweenOperation *)tween:(CGFloat*)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration; 151 | 152 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property period:(PRTweenLerpPeriod *)period timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector; 153 | 154 | - (PRTweenOperation *)addTweenOperation:(PRTweenOperation*)operation; 155 | - (PRTweenOperation *)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)target selector:(SEL)selector; 156 | - (PRTweenOperation *)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)target selector:(SEL)selector timingFunction:(PRTweenTimingFunction)timingFunction; 157 | - (void)removeTweenOperation:(PRTweenOperation*)tweenOperation; 158 | 159 | #if NS_BLOCKS_AVAILABLE 160 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock; 161 | 162 | + (PRTweenOperation *)tween:(CGFloat*)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock; 163 | 164 | + (PRTweenOperation *)lerp:(id)object property:(NSString*)property period:(PRTweenLerpPeriod *)period timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock; 165 | 166 | - (PRTweenOperation *)addTweenPeriod:(PRTweenPeriod *)period updateBlock:(PRTweenUpdateBlock)updateBlock completionBlock:(PRTweenCompleteBlock)completeBlock; 167 | - (PRTweenOperation *)addTweenPeriod:(PRTweenPeriod *)period updateBlock:(PRTweenUpdateBlock)updateBlock completionBlock:(PRTweenCompleteBlock)completionBlock timingFunction:(PRTweenTimingFunction)timingFunction; 168 | #endif 169 | 170 | @end 171 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PRTween/PRTween.m: -------------------------------------------------------------------------------- 1 | 2 | #import "PRTween.h" 3 | 4 | #define kPRTweenFramerate 1.0/60 5 | 6 | @implementation PRTweenPeriod 7 | @synthesize startValue; 8 | @synthesize endValue; 9 | @synthesize tweenedValue; 10 | @synthesize duration; 11 | @synthesize delay; 12 | @synthesize startOffset; 13 | 14 | + (id)periodWithStartValue:(CGFloat)aStartValue endValue:(CGFloat)anEndValue duration:(CGFloat)duration { 15 | PRTweenPeriod *period = [PRTweenPeriod new]; 16 | 17 | period.startValue = period.tweenedValue = aStartValue; 18 | period.endValue = anEndValue; 19 | period.duration = duration; 20 | period.startOffset = [[PRTween sharedInstance] timeOffset]; 21 | 22 | return [period autorelease]; 23 | } 24 | 25 | @end 26 | 27 | @implementation PRTweenLerpPeriod 28 | @synthesize startLerp; 29 | @synthesize endLerp; 30 | @synthesize tweenedLerp; 31 | 32 | + (id)periodWithStartValue:(NSValue*)aStartValue endValue:(NSValue*)anEndValue duration:(CGFloat)duration { 33 | PRTweenLerpPeriod *period = [[self class] new]; 34 | period.startLerp = aStartValue; 35 | period.tweenedLerp = aStartValue; 36 | period.endLerp = anEndValue; 37 | period.duration = duration; 38 | period.startOffset = [[PRTween sharedInstance] timeOffset]; 39 | 40 | return [period autorelease]; 41 | } 42 | 43 | - (void)dealloc { 44 | [startLerp release]; 45 | [endLerp release]; 46 | [tweenedLerp release]; 47 | [super dealloc]; 48 | } 49 | 50 | @end 51 | 52 | @implementation PRTweenCGPointLerpPeriod 53 | 54 | + (id)periodWithStartCGPoint:(CGPoint)aStartPoint endCGPoint:(CGPoint)anEndPoint duration:(CGFloat)duration { 55 | return [PRTweenCGPointLerpPeriod periodWithStartValue:[NSValue valueWithCGPoint:aStartPoint] endValue:[NSValue valueWithCGPoint:anEndPoint] duration:duration]; 56 | } 57 | 58 | - (CGPoint)startCGPoint { return [self.startLerp CGPointValue]; } 59 | - (CGPoint)tweenedCGPoint { return [self.tweenedLerp CGPointValue]; } 60 | - (CGPoint)endCGPoint { return [self.endLerp CGPointValue]; } 61 | 62 | - (NSValue*)tweenedValueForProgress:(CGFloat)progress { 63 | 64 | CGPoint startPoint = self.startCGPoint; 65 | CGPoint endPoint = self.endCGPoint; 66 | CGPoint distance = CGPointMake(endPoint.x - startPoint.x, endPoint.y - startPoint.y); 67 | CGPoint tweenedPoint = CGPointMake(startPoint.x + distance.x * progress, startPoint.y + distance.y * progress); 68 | 69 | return [NSValue valueWithCGPoint:tweenedPoint]; 70 | 71 | } 72 | 73 | - (void)setProgress:(CGFloat)progress { 74 | self.tweenedLerp = [self tweenedValueForProgress:progress]; 75 | } 76 | 77 | @end 78 | 79 | @implementation PRTweenCGRectLerpPeriod 80 | 81 | + (id)periodWithStartCGRect:(CGRect)aStartRect endCGRect:(CGRect)anEndRect duration:(CGFloat)duration { 82 | return [PRTweenCGRectLerpPeriod periodWithStartValue:[NSValue valueWithCGRect:aStartRect] endValue:[NSValue valueWithCGRect:anEndRect] duration:duration]; 83 | } 84 | 85 | - (CGRect)startCGRect { return [self.startLerp CGRectValue]; } 86 | - (CGRect)tweenedCGRect { return [self.tweenedLerp CGRectValue]; } 87 | - (CGRect)endCGRect { return [self.endLerp CGRectValue]; } 88 | 89 | - (NSValue *)tweenedValueForProgress:(CGFloat)progress { 90 | 91 | CGRect startRect = self.startCGRect; 92 | CGRect endRect = self.endCGRect; 93 | CGRect distance = CGRectMake(endRect.origin.x - startRect.origin.x, endRect.origin.y - startRect.origin.y, endRect.size.width - startRect.size.width, endRect.size.height - startRect.size.height); 94 | CGRect tweenedRect = CGRectMake(startRect.origin.x + distance.origin.x * progress, startRect.origin.y + distance.origin.y * progress, startRect.size.width + distance.size.width * progress, startRect.size.height + distance.size.height * progress); 95 | 96 | return [NSValue valueWithCGRect:tweenedRect]; 97 | 98 | } 99 | 100 | - (void)setProgress:(CGFloat)progress { 101 | self.tweenedLerp = [self tweenedValueForProgress:progress]; 102 | } 103 | 104 | @end 105 | 106 | @interface PRTweenOperation () 107 | @property (nonatomic) BOOL canUseBuiltAnimation; 108 | @end 109 | 110 | @implementation PRTweenOperation 111 | @synthesize period; 112 | @synthesize target; 113 | @synthesize updateSelector; 114 | @synthesize completeSelector; 115 | @synthesize timingFunction; 116 | @synthesize boundRef; 117 | @synthesize boundObject; 118 | @synthesize boundGetter; 119 | @synthesize boundSetter; 120 | @synthesize canUseBuiltAnimation; 121 | @synthesize override; 122 | 123 | #if NS_BLOCKS_AVAILABLE 124 | @synthesize updateBlock; 125 | @synthesize completeBlock; 126 | #endif 127 | 128 | - (void)dealloc { 129 | #if NS_BLOCKS_AVAILABLE 130 | [updateBlock release]; 131 | [completeBlock release]; 132 | #endif 133 | [period release]; 134 | [target release]; 135 | [boundObject release]; 136 | [super dealloc]; 137 | } 138 | 139 | @end 140 | 141 | @implementation PRTweenCGPointLerp 142 | 143 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector { 144 | return [PRTween lerp:object property:property period:[PRTweenCGPointLerpPeriod periodWithStartCGPoint:from endCGPoint:to duration:duration] timingFunction:timingFunction target:target completeSelector:selector]; 145 | } 146 | 147 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration delay:(CGFloat)delay timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector { 148 | PRTweenCGPointLerpPeriod *period = [PRTweenCGPointLerpPeriod periodWithStartCGPoint:from endCGPoint:to duration:duration]; 149 | period.delay = delay; 150 | return [PRTween lerp:object property:property period:period timingFunction:timingFunction target:target completeSelector:selector]; 151 | } 152 | 153 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration { 154 | return [PRTweenCGPointLerp lerp:object property:property from:from to:to duration:duration timingFunction:NULL target:nil completeSelector:NULL]; 155 | } 156 | 157 | #if NS_BLOCKS_AVAILABLE 158 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGPoint)from to:(CGPoint)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock { 159 | return [PRTween lerp:object property:property period:[PRTweenCGPointLerpPeriod periodWithStartCGPoint:from endCGPoint:to duration:duration] timingFunction:timingFunction updateBlock:updateBlock completeBlock:completeBlock]; 160 | } 161 | #endif 162 | 163 | @end 164 | 165 | @implementation PRTweenCGRectLerp 166 | 167 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector { 168 | return [PRTween lerp:object property:property period:[PRTweenCGRectLerpPeriod periodWithStartCGRect:from endCGRect:to duration:duration] timingFunction:timingFunction target:target completeSelector:selector]; 169 | } 170 | 171 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration delay:(CGFloat)delay timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector { 172 | PRTweenCGRectLerpPeriod *period = [PRTweenCGRectLerpPeriod periodWithStartCGRect:from endCGRect:to duration:duration]; 173 | period.delay = delay; 174 | return [PRTween lerp:object property:property period:period timingFunction:timingFunction target:target completeSelector:selector]; 175 | } 176 | 177 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration { 178 | return [PRTweenCGRectLerp lerp:object property:property from:from to:to duration:duration timingFunction:NULL target:nil completeSelector:NULL]; 179 | } 180 | 181 | #if NS_BLOCKS_AVAILABLE 182 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property from:(CGRect)from to:(CGRect)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock { 183 | return [PRTweenCGRectLerp lerp:object property:property from:from to:to duration:duration timingFunction:NULL updateBlock:updateBlock completeBlock:completeBlock]; 184 | } 185 | #endif 186 | 187 | @end 188 | 189 | @interface PRTween () 190 | + (SEL)setterFromProperty:(NSString *)property; 191 | - (void)update; 192 | @end 193 | 194 | static PRTween *instance = nil; 195 | static NSArray *animationSelectorsForCoreAnimation = nil; 196 | static NSArray *animationSelectorsForUIView = nil; 197 | 198 | @implementation PRTween 199 | @synthesize timeOffset; 200 | @synthesize defaultTimingFunction; 201 | @synthesize useBuiltInAnimationsWhenPossible; 202 | 203 | + (PRTween *)sharedInstance { 204 | if (instance == nil) { 205 | instance = [[PRTween alloc] init]; 206 | instance.useBuiltInAnimationsWhenPossible = YES; 207 | } 208 | return instance; 209 | } 210 | 211 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector { 212 | 213 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration]; 214 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 215 | operation.period = period; 216 | operation.timingFunction = timingFunction; 217 | operation.target = target; 218 | operation.completeSelector = selector; 219 | operation.boundObject = object; 220 | operation.boundGetter = NSSelectorFromString([NSString stringWithFormat:@"%@", property]); 221 | operation.boundSetter = [PRTween setterFromProperty:property]; 222 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedValue" options:NSKeyValueObservingOptionNew context:NULL]; 223 | 224 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 225 | return operation; 226 | 227 | } 228 | 229 | + (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject*)target completeSelector:(SEL)selector { 230 | 231 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration]; 232 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 233 | operation.period = period; 234 | operation.timingFunction = timingFunction; 235 | operation.target = target; 236 | operation.completeSelector = selector; 237 | operation.boundRef = ref; 238 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedValue" options:NSKeyValueObservingOptionNew context:NULL]; 239 | 240 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 241 | return operation; 242 | 243 | } 244 | 245 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration { 246 | return [PRTween tween:object property:property from:from to:to duration:duration timingFunction:NULL target:nil completeSelector:NULL]; 247 | } 248 | 249 | + (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration { 250 | return [PRTween tween:ref from:from to:to duration:duration timingFunction:NULL target:nil completeSelector:NULL]; 251 | } 252 | 253 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property period:(PRTweenLerpPeriod *)period timingFunction:(PRTweenTimingFunction)timingFunction target:(NSObject *)target completeSelector:(SEL)selector { 254 | 255 | //PRTweenPeriod *period = [PRTweenLerpPeriod periodWithStartValue:from endValue:to duration:duration]; 256 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 257 | operation.period = period; 258 | operation.timingFunction = timingFunction; 259 | operation.target = target; 260 | operation.completeSelector = selector; 261 | operation.boundObject = object; 262 | operation.boundGetter = NSSelectorFromString([NSString stringWithFormat:@"%@", property]); 263 | operation.boundSetter = [PRTween setterFromProperty:property]; 264 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedLerp" options:NSKeyValueObservingOptionNew context:NULL]; 265 | 266 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 267 | return operation; 268 | 269 | } 270 | 271 | #if NS_BLOCKS_AVAILABLE 272 | + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock { 273 | 274 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration]; 275 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 276 | operation.period = period; 277 | operation.timingFunction = timingFunction; 278 | operation.updateBlock = updateBlock; 279 | operation.completeBlock = completeBlock; 280 | operation.boundObject = object; 281 | operation.boundGetter = NSSelectorFromString([NSString stringWithFormat:@"%@", property]); 282 | operation.boundSetter = [PRTween setterFromProperty:property]; 283 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedValue" options:NSKeyValueObservingOptionNew context:NULL]; 284 | 285 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 286 | return operation; 287 | 288 | } 289 | 290 | + (PRTweenOperation *)tween:(CGFloat *)ref from:(CGFloat)from to:(CGFloat)to duration:(CGFloat)duration timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock { 291 | 292 | PRTweenPeriod *period = [PRTweenPeriod periodWithStartValue:from endValue:to duration:duration]; 293 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 294 | operation.period = period; 295 | operation.timingFunction = timingFunction; 296 | operation.updateBlock = updateBlock; 297 | operation.completeBlock = completeBlock; 298 | operation.boundRef = ref; 299 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedValue" options:NSKeyValueObservingOptionNew context:NULL]; 300 | 301 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 302 | return operation; 303 | 304 | } 305 | 306 | + (PRTweenOperation *)lerp:(id)object property:(NSString *)property period:(PRTweenLerpPeriod *)period timingFunction:(PRTweenTimingFunction)timingFunction updateBlock:(PRTweenUpdateBlock)updateBlock completeBlock:(PRTweenCompleteBlock)completeBlock { 307 | 308 | //PRTweenPeriod *period = [PRTweenLerpPeriod periodWithStartValue:from endValue:to duration:duration]; 309 | PRTweenOperation *operation = [[PRTweenOperation new] autorelease]; 310 | operation.period = period; 311 | operation.timingFunction = timingFunction; 312 | operation.updateBlock = updateBlock; 313 | operation.completeBlock = completeBlock; 314 | operation.boundObject = object; 315 | operation.boundGetter = NSSelectorFromString([NSString stringWithFormat:@"%@", property]); 316 | operation.boundSetter = [PRTween setterFromProperty:property]; 317 | [operation addObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedLerp" options:NSKeyValueObservingOptionNew context:NULL]; 318 | 319 | [[PRTween sharedInstance] performSelector:@selector(addTweenOperation:) withObject:operation afterDelay:0]; 320 | return operation; 321 | 322 | } 323 | #endif 324 | 325 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 326 | 327 | PRTweenOperation *operation = (PRTweenOperation*)object; 328 | 329 | if ([operation.period isKindOfClass:[PRTweenLerpPeriod class]]) { 330 | PRTweenLerpPeriod *lerpPeriod = (PRTweenLerpPeriod*)operation.period; 331 | 332 | NSUInteger bufferSize = 0; 333 | NSGetSizeAndAlignment([lerpPeriod.tweenedLerp objCType], &bufferSize, NULL); 334 | void *tweenedValue = malloc(bufferSize); 335 | [lerpPeriod.tweenedLerp getValue:tweenedValue]; 336 | 337 | if (operation.boundObject && [operation.boundObject respondsToSelector:operation.boundGetter] && [operation.boundObject respondsToSelector:operation.boundSetter]) { 338 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[operation.boundObject class] instanceMethodSignatureForSelector:operation.boundSetter]]; 339 | [invocation setTarget:operation.boundObject]; 340 | [invocation setSelector:operation.boundSetter]; 341 | [invocation setArgument:tweenedValue atIndex:2]; 342 | [invocation invoke]; 343 | } 344 | 345 | free(tweenedValue); 346 | 347 | } else { 348 | 349 | CGFloat tweenedValue = operation.period.tweenedValue; 350 | 351 | if (operation.boundObject && [operation.boundObject respondsToSelector:operation.boundGetter] && [operation.boundObject respondsToSelector:operation.boundSetter]) { 352 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[operation.boundObject class] instanceMethodSignatureForSelector:operation.boundSetter]]; 353 | [invocation setTarget:operation.boundObject]; 354 | [invocation setSelector:operation.boundSetter]; 355 | [invocation setArgument:&tweenedValue atIndex:2]; 356 | [invocation invoke]; 357 | } else if (operation.boundRef) { 358 | *operation.boundRef = tweenedValue; 359 | } 360 | 361 | } 362 | 363 | } 364 | 365 | - (id)init { 366 | self = [super init]; 367 | if (self != nil) { 368 | tweenOperations = [[NSMutableArray alloc] init]; 369 | expiredTweenOperations = [[NSMutableArray alloc] init]; 370 | timeOffset = 0; 371 | if (timer == nil) { 372 | timer = [NSTimer scheduledTimerWithTimeInterval:kPRTweenFramerate target:self selector:@selector(update) userInfo:nil repeats:YES]; 373 | } 374 | self.defaultTimingFunction = &PRTweenTimingFunctionQuadInOut; 375 | } 376 | return self; 377 | } 378 | 379 | - (PRTweenOperation*)addTweenOperation:(PRTweenOperation*)operation { 380 | 381 | if (useBuiltInAnimationsWhenPossible && !operation.override) { 382 | 383 | if (animationSelectorsForCoreAnimation == nil) { 384 | animationSelectorsForCoreAnimation = [[NSArray alloc] initWithObjects: 385 | @"setBounds:", // CGRect 386 | @"setPosition:", // CGPoint 387 | @"setZPosition:", // CGFloat 388 | @"setAnchorPoint:", // CGPoint 389 | @"setAnchorPointZ:", // CGFloat 390 | //@"setTransform:", // CATransform3D 391 | //@"setSublayerTransform:", // CATransform3D 392 | @"setFrame:", // CGRect 393 | @"setContentsRect" // CGRect 394 | @"setContentsScale:", // CGFloat 395 | @"setContentsCenter:", // CGPoint 396 | //@"setBackgroundColor:", // CGColorRef 397 | @"setCornerRadius:", // CGFloat 398 | @"setBorderWidth:", // CGFloat 399 | @"setOpacity:", // CGFloat 400 | //@"setShadowColor:", // CGColorRef 401 | @"setShadowOpacity:", // CGFloat 402 | @"setShadowOffset:", // CGSize 403 | @"setShadowRadius:", // CGFloat 404 | //@"setShadowPath:", 405 | nil]; 406 | } 407 | 408 | if (animationSelectorsForUIView == nil) { 409 | animationSelectorsForUIView = [[NSArray alloc] initWithObjects: 410 | @"setFrame:", // CGRect 411 | @"setBounds:", // CGRect 412 | @"setCenter:", // CGPoint 413 | @"setTransform:", // CGAffineTransform 414 | @"setAlpha:", // CGFloat 415 | //@"setBackgroundColor:", // UIColor 416 | @"setContentStretch:", // CGRect 417 | nil]; 418 | } 419 | 420 | if (operation.boundSetter && operation.boundObject && !(operation.timingFunction == &PRTweenTimingFunctionCADefault || 421 | operation.timingFunction == &PRTweenTimingFunctionCAEaseIn || 422 | operation.timingFunction == &PRTweenTimingFunctionCAEaseOut || 423 | operation.timingFunction == &PRTweenTimingFunctionCAEaseInOut || 424 | operation.timingFunction == &PRTweenTimingFunctionCALinear || 425 | operation.timingFunction == &PRTweenTimingFunctionUIViewEaseIn || 426 | operation.timingFunction == &PRTweenTimingFunctionUIViewEaseOut || 427 | operation.timingFunction == &PRTweenTimingFunctionUIViewEaseInOut || 428 | operation.timingFunction == &PRTweenTimingFunctionUIViewLinear || 429 | operation.timingFunction == NULL)) { 430 | goto complete; 431 | } 432 | 433 | 434 | if (operation.boundSetter && operation.boundObject && [operation.boundObject isKindOfClass:[CALayer class]]) { 435 | for (NSString *selector in animationSelectorsForCoreAnimation) { 436 | NSString *setter = NSStringFromSelector(operation.boundSetter); 437 | if ([selector isEqualToString:setter]) { 438 | NSLog(@"Using Core Animation for %@", NSStringFromSelector(operation.boundSetter)); 439 | operation.canUseBuiltAnimation = YES; 440 | 441 | NSString *propertyUnformatted = [selector stringByReplacingCharactersInRange:NSMakeRange(0, 3) withString:@""]; 442 | NSString *propertyFormatted = [[propertyUnformatted stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[[propertyUnformatted substringToIndex:1] lowercaseString]] substringToIndex:[propertyUnformatted length] - 1]; 443 | //NSLog(@"%@", propertyFormatted); 444 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:propertyFormatted]; 445 | animation.duration = operation.period.duration; 446 | 447 | if (![operation.period isKindOfClass:[PRTweenLerpPeriod class]] && ![operation.period conformsToProtocol:@protocol(PRTweenLerpPeriod)]) { 448 | animation.fromValue = [NSNumber numberWithFloat:operation.period.startValue]; 449 | animation.toValue = [NSNumber numberWithFloat:operation.period.endValue]; 450 | } else { 451 | PRTweenLerpPeriod *period = (PRTweenLerpPeriod*)operation.period; 452 | animation.fromValue = period.startLerp; 453 | animation.toValue = period.endLerp; 454 | } 455 | 456 | if (operation.timingFunction == &PRTweenTimingFunctionCAEaseIn) { 457 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 458 | } else if (operation.timingFunction == &PRTweenTimingFunctionCAEaseOut) { 459 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 460 | } else if (operation.timingFunction == &PRTweenTimingFunctionCAEaseInOut) { 461 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 462 | } else if (operation.timingFunction == &PRTweenTimingFunctionCALinear) { 463 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 464 | } else { 465 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 466 | } 467 | 468 | [operation.boundObject setValue:animation.toValue forKeyPath:propertyFormatted]; 469 | [operation.boundObject addAnimation:animation forKey:@"PRTweenCAAnimation"]; 470 | 471 | goto complete; 472 | } 473 | } 474 | } else if (operation.boundSetter && operation.boundObject && [operation.boundObject isKindOfClass:[UIView class]]) { 475 | for (NSString *selector in animationSelectorsForUIView) { 476 | NSString *setter = NSStringFromSelector(operation.boundSetter); 477 | if ([selector isEqualToString:setter]) { 478 | operation.canUseBuiltAnimation = YES; 479 | 480 | NSString *propertyUnformatted = [selector stringByReplacingCharactersInRange:NSMakeRange(0, 3) withString:@""]; 481 | NSString *propertyFormatted = [[propertyUnformatted stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[[propertyUnformatted substringToIndex:1] lowercaseString]] substringToIndex:[propertyUnformatted length] - 1]; 482 | 483 | NSValue *fromValue = nil; 484 | NSValue *toValue = nil; 485 | 486 | if (![operation.period isKindOfClass:[PRTweenLerpPeriod class]] && ![operation.period conformsToProtocol:@protocol(PRTweenLerpPeriod)]) { 487 | fromValue = [NSNumber numberWithFloat:operation.period.startValue]; 488 | toValue = [NSNumber numberWithFloat:operation.period.endValue]; 489 | } else { 490 | PRTweenLerpPeriod *period = (PRTweenLerpPeriod*)operation.period; 491 | fromValue = period.startLerp; 492 | toValue = period.endLerp; 493 | } 494 | 495 | [operation.boundObject setValue:fromValue forKeyPath:propertyFormatted]; 496 | [UIView beginAnimations:nil context:NULL]; 497 | [UIView setAnimationDuration:operation.period.duration]; 498 | 499 | if (operation.timingFunction == &PRTweenTimingFunctionUIViewEaseIn) { 500 | [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 501 | } else if (operation.timingFunction == &PRTweenTimingFunctionUIViewEaseOut) { 502 | [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 503 | } else if (operation.timingFunction == &PRTweenTimingFunctionUIViewEaseInOut) { 504 | [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 505 | } else if (operation.timingFunction == &PRTweenTimingFunctionUIViewLinear) { 506 | [UIView setAnimationCurve:UIViewAnimationCurveLinear]; 507 | } 508 | 509 | [operation.boundObject setValue:toValue forKeyPath:propertyFormatted]; 510 | [UIView commitAnimations]; 511 | 512 | goto complete; 513 | } 514 | } 515 | } 516 | 517 | } 518 | 519 | complete: 520 | [tweenOperations addObject:operation]; 521 | return operation; 522 | } 523 | 524 | #if NS_BLOCKS_AVAILABLE 525 | - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period 526 | updateBlock:(void (^)(PRTweenPeriod *period))updateBlock 527 | completionBlock:(void (^)())completeBlock { 528 | return [self addTweenPeriod:period updateBlock:updateBlock completionBlock:completeBlock timingFunction:self.defaultTimingFunction]; 529 | } 530 | 531 | - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period 532 | updateBlock:(void (^)(PRTweenPeriod *period))anUpdateBlock 533 | completionBlock:(void (^)())completeBlock 534 | timingFunction:(PRTweenTimingFunction)timingFunction { 535 | 536 | PRTweenOperation *tweenOperation = [[PRTweenOperation new] autorelease]; 537 | tweenOperation.period = period; 538 | tweenOperation.timingFunction = timingFunction; 539 | tweenOperation.updateBlock = anUpdateBlock; 540 | tweenOperation.completeBlock = completeBlock; 541 | return [self addTweenOperation:tweenOperation]; 542 | 543 | } 544 | #endif 545 | 546 | - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)target selector:(SEL)selector { 547 | return [self addTweenPeriod:period target:target selector:selector timingFunction:self.defaultTimingFunction]; 548 | } 549 | 550 | - (PRTweenOperation*)addTweenPeriod:(PRTweenPeriod *)period target:(NSObject *)target selector:(SEL)selector timingFunction:(PRTweenTimingFunction)timingFunction { 551 | 552 | PRTweenOperation *tweenOperation = [[PRTweenOperation new] autorelease]; 553 | tweenOperation.period = period; 554 | tweenOperation.target = target; 555 | tweenOperation.timingFunction = timingFunction; 556 | tweenOperation.updateSelector = selector; 557 | 558 | return [self addTweenOperation:tweenOperation]; 559 | 560 | } 561 | 562 | - (void)removeTweenOperation:(PRTweenOperation *)tweenOperation { 563 | if (tweenOperation != nil) { 564 | if ([tweenOperations containsObject:tweenOperation]) { 565 | [expiredTweenOperations addObject:tweenOperation]; 566 | } 567 | } 568 | } 569 | 570 | + (SEL)setterFromProperty:(NSString *)property { 571 | return NSSelectorFromString([NSString stringWithFormat:@"set%@:", [property stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[[property substringToIndex:1] capitalizedString]]]); 572 | } 573 | 574 | - (void)update { 575 | timeOffset += kPRTweenFramerate; 576 | 577 | for (PRTweenOperation *tweenOperation in tweenOperations) { 578 | 579 | PRTweenPeriod *period = tweenOperation.period; 580 | 581 | // if operation is delayed, pass over it for now 582 | if (timeOffset <= period.startOffset + period.delay) { 583 | continue; 584 | } 585 | 586 | CGFloat (*timingFunction)(CGFloat, CGFloat, CGFloat, CGFloat) = tweenOperation.timingFunction; 587 | if (timingFunction == NULL) { 588 | timingFunction = self.defaultTimingFunction; 589 | } 590 | 591 | if (timingFunction != NULL && tweenOperation.canUseBuiltAnimation == NO) { 592 | if (timeOffset <= period.startOffset + period.delay + period.duration) { 593 | if ([period isKindOfClass:[PRTweenLerpPeriod class]]) { 594 | if ([period conformsToProtocol:@protocol(PRTweenLerpPeriod)]) { 595 | PRTweenLerpPeriod *lerpPeriod = (PRTweenLerpPeriod *)period; 596 | CGFloat progress = timingFunction(timeOffset - period.startOffset - period.delay, 0.0, 1.0, period.duration); 597 | [lerpPeriod setProgress:progress]; 598 | } else { 599 | // @TODO: Throw exception 600 | NSLog(@"Class doesn't conform to PRTweenLerp"); 601 | } 602 | } else { 603 | // if tween operation is valid, calculate tweened value using timing function 604 | period.tweenedValue = timingFunction(timeOffset - period.startOffset - period.delay, period.startValue, period.endValue - period.startValue, period.duration); 605 | } 606 | } else { 607 | // move expired tween operations to list for cleanup 608 | period.tweenedValue = period.endValue; 609 | [expiredTweenOperations addObject:tweenOperation]; 610 | } 611 | 612 | NSObject *target = tweenOperation.target; 613 | SEL selector = tweenOperation.updateSelector; 614 | 615 | if (period != nil) { 616 | if (target != nil && selector != NULL) { 617 | [target performSelector:selector withObject:period afterDelay:0]; 618 | } 619 | 620 | // Check to see if blocks/GCD are supported 621 | if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_4_0) { 622 | // fire off update block 623 | if (tweenOperation.updateBlock != NULL) { 624 | tweenOperation.updateBlock(period); 625 | } 626 | } 627 | } 628 | } else if (tweenOperation.canUseBuiltAnimation == YES) { 629 | if (timeOffset > period.startOffset + period.delay + period.duration) { 630 | [expiredTweenOperations addObject:tweenOperation]; 631 | } 632 | } 633 | } 634 | 635 | // clean up expired tween operations 636 | for (PRTweenOperation *tweenOperation in expiredTweenOperations) { 637 | 638 | if (tweenOperation.completeSelector) [tweenOperation.target performSelector:tweenOperation.completeSelector withObject:nil afterDelay:0]; 639 | // Check to see if blocks/GCD are supported 640 | if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_4_0) { 641 | if (tweenOperation.completeBlock != NULL) { 642 | tweenOperation.completeBlock(); 643 | } 644 | } 645 | 646 | // @HACK: Come up with a better pattern for removing observers. 647 | @try { 648 | [tweenOperation removeObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedValue"]; 649 | } @catch (id exception) { 650 | } 651 | @try { 652 | [tweenOperation removeObserver:[PRTween sharedInstance] forKeyPath:@"period.tweenedLerp"]; 653 | } @catch (id exception) { 654 | } 655 | 656 | [tweenOperations removeObject:tweenOperation]; 657 | tweenOperation = nil; 658 | } 659 | [expiredTweenOperations removeAllObjects]; 660 | } 661 | 662 | - (void)dealloc { 663 | [tweenOperations release]; 664 | [expiredTweenOperations release]; 665 | [timer invalidate]; 666 | 667 | [super dealloc]; 668 | } 669 | 670 | @end 671 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PRTween/PRTweenTimingFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | These timing functions are adapted from Robert Penner's excellent AS2 easing equations. 4 | For more information, check out http://robertpenner.com/easing/ 5 | 6 | -- 7 | 8 | TERMS OF USE - EASING EQUATIONS 9 | 10 | Open source under the BSD License. 11 | 12 | Copyright © 2001 Robert Penner 13 | All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 16 | 17 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 18 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 19 | Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | 22 | */ 23 | 24 | #import 25 | #import 26 | 27 | CGFloat PRTweenTimingFunctionLinear (CGFloat, CGFloat, CGFloat, CGFloat); 28 | 29 | CGFloat PRTweenTimingFunctionBackOut (CGFloat, CGFloat, CGFloat, CGFloat); 30 | CGFloat PRTweenTimingFunctionBackIn (CGFloat, CGFloat, CGFloat, CGFloat); 31 | CGFloat PRTweenTimingFunctionBackInOut (CGFloat, CGFloat, CGFloat, CGFloat); 32 | 33 | CGFloat PRTweenTimingFunctionBounceOut (CGFloat, CGFloat, CGFloat, CGFloat); 34 | CGFloat PRTweenTimingFunctionBounceIn (CGFloat, CGFloat, CGFloat, CGFloat); 35 | CGFloat PRTweenTimingFunctionBounceInOut (CGFloat, CGFloat, CGFloat, CGFloat); 36 | 37 | CGFloat PRTweenTimingFunctionCircOut (CGFloat, CGFloat, CGFloat, CGFloat); 38 | CGFloat PRTweenTimingFunctionCircIn (CGFloat, CGFloat, CGFloat, CGFloat); 39 | CGFloat PRTweenTimingFunctionCircInOut (CGFloat, CGFloat, CGFloat, CGFloat); 40 | 41 | CGFloat PRTweenTimingFunctionCubicOut (CGFloat, CGFloat, CGFloat, CGFloat); 42 | CGFloat PRTweenTimingFunctionCubicIn (CGFloat, CGFloat, CGFloat, CGFloat); 43 | CGFloat PRTweenTimingFunctionCubicInOut (CGFloat, CGFloat, CGFloat, CGFloat); 44 | 45 | CGFloat PRTweenTimingFunctionElasticOut (CGFloat, CGFloat, CGFloat, CGFloat); 46 | CGFloat PRTweenTimingFunctionElasticIn (CGFloat, CGFloat, CGFloat, CGFloat); 47 | CGFloat PRTweenTimingFunctionElasticInOut (CGFloat, CGFloat, CGFloat, CGFloat); 48 | 49 | CGFloat PRTweenTimingFunctionExpoOut (CGFloat, CGFloat, CGFloat, CGFloat); 50 | CGFloat PRTweenTimingFunctionExpoIn (CGFloat, CGFloat, CGFloat, CGFloat); 51 | CGFloat PRTweenTimingFunctionExpoInOut (CGFloat, CGFloat, CGFloat, CGFloat); 52 | 53 | CGFloat PRTweenTimingFunctionQuadOut (CGFloat, CGFloat, CGFloat, CGFloat); 54 | CGFloat PRTweenTimingFunctionQuadIn (CGFloat, CGFloat, CGFloat, CGFloat); 55 | CGFloat PRTweenTimingFunctionQuadInOut (CGFloat, CGFloat, CGFloat, CGFloat); 56 | 57 | CGFloat PRTweenTimingFunctionQuartOut (CGFloat, CGFloat, CGFloat, CGFloat); 58 | CGFloat PRTweenTimingFunctionQuartIn (CGFloat, CGFloat, CGFloat, CGFloat); 59 | CGFloat PRTweenTimingFunctionQuartInOut (CGFloat, CGFloat, CGFloat, CGFloat); 60 | 61 | CGFloat PRTweenTimingFunctionQuintOut (CGFloat, CGFloat, CGFloat, CGFloat); 62 | CGFloat PRTweenTimingFunctionQuintIn (CGFloat, CGFloat, CGFloat, CGFloat); 63 | CGFloat PRTweenTimingFunctionQuintInOut (CGFloat, CGFloat, CGFloat, CGFloat); 64 | 65 | CGFloat PRTweenTimingFunctionSineOut (CGFloat, CGFloat, CGFloat, CGFloat); 66 | CGFloat PRTweenTimingFunctionSineIn (CGFloat, CGFloat, CGFloat, CGFloat); 67 | CGFloat PRTweenTimingFunctionSineInOut (CGFloat, CGFloat, CGFloat, CGFloat); 68 | 69 | CGFloat PRTweenTimingFunctionCALinear (CGFloat, CGFloat, CGFloat, CGFloat); 70 | CGFloat PRTweenTimingFunctionCAEaseIn (CGFloat, CGFloat, CGFloat, CGFloat); 71 | CGFloat PRTweenTimingFunctionCAEaseOut (CGFloat, CGFloat, CGFloat, CGFloat); 72 | CGFloat PRTweenTimingFunctionCAEaseInOut (CGFloat, CGFloat, CGFloat, CGFloat); 73 | CGFloat PRTweenTimingFunctionCADefault (CGFloat, CGFloat, CGFloat, CGFloat); 74 | 75 | CGFloat PRTweenTimingFunctionUIViewLinear (CGFloat, CGFloat, CGFloat, CGFloat); 76 | CGFloat PRTweenTimingFunctionUIViewEaseIn (CGFloat, CGFloat, CGFloat, CGFloat); 77 | CGFloat PRTweenTimingFunctionUIViewEaseOut (CGFloat, CGFloat, CGFloat, CGFloat); 78 | CGFloat PRTweenTimingFunctionUIViewEaseInOut (CGFloat, CGFloat, CGFloat, CGFloat); 79 | 80 | CGFloat (*PRTweenTimingFunctionCACustom(CAMediaTimingFunction *timingFunction))(CGFloat, CGFloat, CGFloat, CGFloat); 81 | 82 | 83 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/PPDragDropBadgeView/PRTween/PRTweenTimingFunctions.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | These timing functions are adapted from Robert Penner's excellent AS2 easing equations. 4 | For more information, check out http://robertpenner.com/easing/ 5 | 6 | -- 7 | 8 | TERMS OF USE - EASING EQUATIONS 9 | 10 | Open source under the BSD License. 11 | 12 | Copyright © 2001 Robert Penner 13 | All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 16 | 17 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 18 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 19 | Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | 22 | */ 23 | 24 | #import "PRTweenTimingFunctions.h" 25 | 26 | CGFloat PRTweenTimingFunctionLinear (CGFloat time, CGFloat begin, CGFloat change, CGFloat duration) { 27 | return change * time / duration + begin; 28 | } 29 | 30 | CGFloat PRTweenTimingFunctionBackOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 31 | CGFloat s = 1.70158; 32 | return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 33 | } 34 | 35 | CGFloat PRTweenTimingFunctionBackIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 36 | CGFloat s = 1.70158; 37 | return c*(t/=d)*t*((s+1)*t - s) + b; 38 | } 39 | 40 | CGFloat PRTweenTimingFunctionBackInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 41 | CGFloat s = 1.70158; 42 | if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 43 | return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 44 | } 45 | 46 | CGFloat PRTweenTimingFunctionBounceOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 47 | if ((t/=d) < (1/2.75)) { 48 | return c*(7.5625*t*t) + b; 49 | } else if (t < (2/2.75)) { 50 | return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 51 | } else if (t < (2.5/2.75)) { 52 | return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 53 | } else { 54 | return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 55 | } 56 | } 57 | 58 | CGFloat PRTweenTimingFunctionBounceIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 59 | return c - PRTweenTimingFunctionBounceOut(d-t, 0, c, d) + b; 60 | } 61 | 62 | CGFloat PRTweenTimingFunctionBounceInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 63 | if (t < d/2) return PRTweenTimingFunctionBounceIn(t*2, 0, c, d) * .5 + b; 64 | else return PRTweenTimingFunctionBounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b; 65 | } 66 | 67 | CGFloat PRTweenTimingFunctionCircOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 68 | return c * sqrt(1 - (t=t/d-1)*t) + b; 69 | } 70 | 71 | CGFloat PRTweenTimingFunctionCircIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 72 | return -c * (sqrt(1 - (t/=d)*t) - 1) + b; 73 | } 74 | 75 | CGFloat PRTweenTimingFunctionCircInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 76 | if ((t/=d/2) < 1) return -c/2 * (sqrt(1 - t*t) - 1) + b; 77 | return c/2 * (sqrt(1 - (t-=2)*t) + 1) + b; 78 | } 79 | 80 | CGFloat PRTweenTimingFunctionCubicOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 81 | return c*((t=t/d-1)*t*t + 1) + b; 82 | } 83 | 84 | CGFloat PRTweenTimingFunctionCubicIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 85 | return c*(t/=d)*t*t + b; 86 | } 87 | 88 | CGFloat PRTweenTimingFunctionCubicInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 89 | if ((t/=d/2) < 1) return c/2*t*t*t + b; 90 | return c/2*((t-=2)*t*t + 2) + b; 91 | } 92 | 93 | CGFloat PRTweenTimingFunctionElasticOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 94 | CGFloat p = d*.3; 95 | CGFloat s, a; 96 | if (t==0) return b; if ((t/=d)==1) return b+c; 97 | if (!a || a < ABS(c)) { a=c; s=p/4; } 98 | else s = p/(2*M_PI) * asin (c/a); 99 | return (a*pow(2,-10*t) * sin( (t*d-s)*(2*M_PI)/p ) + c + b); 100 | } 101 | 102 | CGFloat PRTweenTimingFunctionElasticIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 103 | CGFloat p = d*.3; 104 | CGFloat s, a; 105 | if (t==0) return b; if ((t/=d)==1) return b+c; 106 | if (!a || a < ABS(c)) { a=c; s=p/4; } 107 | else s = p/(2*M_PI) * asin (c/a); 108 | return -(a*pow(2,10*(t-=1)) * sin( (t*d-s)*(2*M_PI)/p )) + b; 109 | } 110 | 111 | CGFloat PRTweenTimingFunctionElasticInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 112 | CGFloat p = d*(.3*1.5); 113 | CGFloat s, a; 114 | if (t==0) return b; if ((t/=d/2)==2) return b+c; 115 | if (!a || a < ABS(c)) { a=c; s=p/4; } 116 | else s = p/(2*M_PI) * asin (c/a); 117 | if (t < 1) return -.5*(a*pow(2,10*(t-=1)) * sin( (t*d-s)*(2*M_PI)/p )) + b; 118 | return a*pow(2,-10*(t-=1)) * sin( (t*d-s)*(2*M_PI)/p )*.5 + c + b; 119 | } 120 | 121 | CGFloat PRTweenTimingFunctionExpoOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 122 | return (t==d) ? b+c : c * (-pow(2, -10 * t/d) + 1) + b; 123 | } 124 | 125 | CGFloat PRTweenTimingFunctionExpoIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 126 | return (t==0) ? b : c * pow(2, 10 * (t/d - 1)) + b; 127 | } 128 | 129 | CGFloat PRTweenTimingFunctionExpoInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 130 | if (t==0) return b; 131 | if (t==d) return b+c; 132 | if ((t/=d/2) < 1) return c/2 * pow(2, 10 * (t - 1)) + b; 133 | return c/2 * (-pow(2, -10 * --t) + 2) + b; 134 | } 135 | 136 | CGFloat PRTweenTimingFunctionQuadOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 137 | return -c *(t/=d)*(t-2) + b; 138 | } 139 | 140 | CGFloat PRTweenTimingFunctionQuadIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 141 | return c*(t/=d)*t + b; 142 | } 143 | 144 | CGFloat PRTweenTimingFunctionQuadInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 145 | if ((t/=d/2) < 1) return c/2*t*t + b; 146 | return -c/2 * ((--t)*(t-2) - 1) + b; 147 | } 148 | 149 | CGFloat PRTweenTimingFunctionQuartOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 150 | return -c * ((t=t/d-1)*t*t*t - 1) + b; 151 | } 152 | 153 | CGFloat PRTweenTimingFunctionQuartIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 154 | return c*(t/=d)*t*t*t + b; 155 | } 156 | 157 | CGFloat PRTweenTimingFunctionQuartInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 158 | if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 159 | return -c/2 * ((t-=2)*t*t*t - 2) + b; 160 | } 161 | 162 | CGFloat PRTweenTimingFunctionQuintOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 163 | return c*(t/=d)*t*t*t*t + b; 164 | } 165 | 166 | CGFloat PRTweenTimingFunctionQuintIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 167 | return c*((t=t/d-1)*t*t*t*t + 1) + b; 168 | } 169 | 170 | CGFloat PRTweenTimingFunctionQuintInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 171 | if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 172 | return c/2*((t-=2)*t*t*t*t + 2) + b; 173 | } 174 | 175 | CGFloat PRTweenTimingFunctionSineOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 176 | return c * sin(t/d * (M_PI/2)) + b; 177 | } 178 | 179 | CGFloat PRTweenTimingFunctionSineIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 180 | return -c * cos(t/d * (M_PI/2)) + c + b; 181 | } 182 | 183 | CGFloat PRTweenTimingFunctionSineInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { 184 | return -c/2 * (cos(M_PI*t/d) - 1) + b; 185 | } 186 | 187 | CGFloat PRTweenTimingFunctionCALinear (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 188 | CGFloat PRTweenTimingFunctionCAEaseIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 189 | CGFloat PRTweenTimingFunctionCAEaseOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 190 | CGFloat PRTweenTimingFunctionCAEaseInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 191 | CGFloat PRTweenTimingFunctionCADefault (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 192 | 193 | CGFloat PRTweenTimingFunctionUIViewLinear (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 194 | CGFloat PRTweenTimingFunctionUIViewEaseIn (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 195 | CGFloat PRTweenTimingFunctionUIViewEaseOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 196 | CGFloat PRTweenTimingFunctionUIViewEaseInOut (CGFloat t, CGFloat b, CGFloat c, CGFloat d) { return 0; } 197 | 198 | CGFloat (*PRTweenTimingFunctionCACustom(CAMediaTimingFunction *timingFunction))(CGFloat, CGFloat, CGFloat, CGFloat) { 199 | return &PRTweenTimingFunctionLinear; 200 | } -------------------------------------------------------------------------------- /PPDragDropBadgeView/SimpleViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleViewController.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SimpleViewController : UIViewController 12 | 13 | @property (nonatomic, weak) IBOutlet UIView* container; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/SimpleViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleViewController.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "SimpleViewController.h" 10 | #import "PPDragDropBadgeView.h" 11 | 12 | @interface SimpleViewController () { 13 | PPDragDropBadgeView* _badgeView; 14 | PPDragDropBadgeView* _badgeView1; 15 | 16 | } 17 | 18 | @end 19 | 20 | @implementation SimpleViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view from its nib. 25 | 26 | { 27 | _badgeView = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(50, 100, 25, 25) dragdropCompletion:^{ 28 | NSLog(@"Drag Drop Done."); 29 | }]; 30 | 31 | _badgeView.text = @"8"; 32 | [self.view addSubview:_badgeView]; 33 | } 34 | 35 | { 36 | _badgeView1 = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(50, 50, 25, 25) dragdropCompletion:^{ 37 | NSLog(@"Drag Drop Done."); 38 | }]; 39 | 40 | _badgeView1.text = @"8"; 41 | [self.container addSubview:_badgeView1]; 42 | } 43 | } 44 | 45 | - (IBAction)onResetButtonPressed:(id)sender { 46 | _badgeView.text = @"6"; 47 | _badgeView1.text = @"9"; 48 | } 49 | 50 | - (void)didReceiveMemoryWarning { 51 | [super didReceiveMemoryWarning]; 52 | // Dispose of any resources that can be recreated. 53 | } 54 | 55 | /* 56 | #pragma mark - Navigation 57 | 58 | // In a storyboard-based application, you will often want to do a little preparation before navigation 59 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 60 | // Get the new view controller using [segue destinationViewController]. 61 | // Pass the selected object to the new view controller. 62 | } 63 | */ 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/SimpleViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TabbarViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TabbarViewController.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TabbarViewController : UIViewController 12 | 13 | @property (nonatomic, weak) IBOutlet UITabBar* tabbar; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TabbarViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TabbarViewController.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "TabbarViewController.h" 10 | #import "PPDragDropBadgeView.h" 11 | 12 | @interface TabbarViewController () 13 | 14 | @end 15 | 16 | @implementation TabbarViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view from its nib. 21 | 22 | PPDragDropBadgeView* badge = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(20, 10, 25, 25)]; 23 | badge.text = @"8"; 24 | [self.tabbar addSubview:badge]; 25 | } 26 | 27 | - (void)didReceiveMemoryWarning { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | /* 33 | #pragma mark - Navigation 34 | 35 | // In a storyboard-based application, you will often want to do a little preparation before navigation 36 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 37 | // Get the new view controller using [segue destinationViewController]. 38 | // Pass the selected object to the new view controller. 39 | } 40 | */ 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TabbarViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewCell.h 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PPDragDropBadgeView.h" 11 | 12 | @interface TableViewCell : UITableViewCell 13 | 14 | @property (nonatomic, strong) PPDragDropBadgeView* badgeView; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewCell.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 10/29/15. 6 | // Copyright © 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import "TableViewCell.h" 10 | 11 | @implementation TableViewCell 12 | 13 | - (void)awakeFromNib { 14 | // Initialization code 15 | 16 | self.badgeView = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(self.bounds.size.width-50, 20, 25, 25) dragdropCompletion:^{ 17 | NSLog(@"TableViewCell drag done."); 18 | }]; 19 | 20 | self.badgeView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; 21 | [self addSubview:self.badgeView]; 22 | } 23 | 24 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 25 | [super setSelected:selected animated:animated]; 26 | 27 | // Configure the view for the selected state 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/TableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PPDragDropBadgeView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PPDragDropBadgeView 4 | // 5 | // Created by StarNet on 3/30/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | /* 异常退出捕获 */ 13 | void uncaughtExceptionHandler(NSException *exception) { 14 | NSArray *arr = [exception callStackSymbols]; 15 | NSString *reason = [exception reason]; 16 | NSString *name = [exception name]; 17 | 18 | NSString *body = [NSString stringWithFormat:@"&body=%@\n\n原因:\n%@\n\n调用栈:\n%@", name, reason,[arr componentsJoinedByString:@"\r\n"]]; 19 | 20 | NSLog(@"%@", body); 21 | sleep(1); 22 | } 23 | 24 | int main(int argc, char * argv[]) { 25 | @autoreleasepool { 26 | NSSetUncaughtExceptionHandler (&uncaughtExceptionHandler); 27 | 28 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /PPDragDropBadgeViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | eVideo.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PPDragDropBadgeViewTests/PPDragDropBadgeViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PPDragDropBadgeViewTests.m 3 | // PPDragDropBadgeViewTests 4 | // 5 | // Created by StarNet on 3/30/15. 6 | // Copyright (c) 2015 StarNet. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface PPDragDropBadgeViewTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation PPDragDropBadgeViewTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PPDragDropBadgeView 2 | PPDragDropBadgeView is a badge view which able to drag and drop. Just like QQ 5.0 badge view. 3 | ![image](https://github.com/smallmuou/PPDragDropBadgeView/blob/master/PPDragDropBadgeView.gif) 4 | 5 | * Support iOS 5.0+ ARC 6 | 7 | ### Configure 8 | * Checkout PPDragDropBadgeView from github. 9 | * Copy PPDragDropBadgeView folder to your project. 10 | * Go to 'TARGET' -> 'Build Phases' -> 'Complile Sources', add compliler flags '-fno-objc-arc' for 'PRTween.m' and 'PRTweenTimingFunctions.m' 11 | * Done. 12 | 13 | You can also refer to the example project provided by me. 14 | 15 | ### Usage 16 | * Q: How to use PPDragDropBadgeView? 17 | * A: Very simple, you only follow the down code. 18 | 19 |
20 | PPDragDropBadgeView* badgeView \
21 | = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(0, 0, 20, 20) dragdropCompletion:^{
22 |                                                          NSLog(@"Drag drop done.");
23 |                                            }];
24 | badgeView.text = @"6";
25 | 
26 | 27 | * Q: Does it can be customized? 28 | * A: Of course, You can see the propertys provided by me. 29 |
30 | 	/** The completion block when drag drop done. */
31 | 	@property (nonatomic, copy) void(^dragdropCompletion)();
32 | 	
33 | 	/** The tint color of badge view. Default is red */
34 | 	@property (nonatomic, strong) UIColor* tintColor;
35 | 	
36 | 	/** The text of badge view. */
37 | 	@property (nonatomic, strong) NSString* text;
38 | 
39 | 40 | ### Note 41 | you must use addSubview instead of directly use it. like 42 |
43 | PPDragDropBadgeView* badge = [[PPDragDropBadgeView alloc] initWithFrame:CGRectMake(10, 10, 25, 25)];
44 | badge.text = @"8";
45 | 
46 | //you must add to container first instead of [[UIBarButtonItem alloc] initWithCustomView:badge]
47 | UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
48 | container.backgroundColor = [UIColor clearColor];
49 | [container addSubview:badge];
50 | 
51 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:container];
52 | 53 | ### History 54 | * v2.1 (October 29, 2015) 55 | * Fix bug, it can on the top view some case. 56 | * Fix bug, it will crash when drag sometimes. 57 | * v2.0 (July 2, 2015) 58 | * Fix bug, it can scroll tableview when badage in cell. 59 | * v1.2 (June 18, 2015) 60 | * Fix bug, it does't drag when in innner viewcontroller. 61 | * v1.1 (May 8, 2015) 62 | * Fix Bug, it will crash when drag sometimes. 63 | * v1.0 (March 30, 2015) 64 | * First release. 65 | 66 | ### License 67 | The code follows MIT Lisence. 68 | 69 | ### Contact 70 | If you have any questions with use it or found some bugs, you can mail to me. I will get back to you in time. The follow is my email address: 71 | lvyexuwenfa100@126.com --------------------------------------------------------------------------------