Skip to content

Commit 4e06ea8

Browse files
committed
为UIKitDynamics添加README.md
1 parent 93fac4e commit 4e06ea8

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

UIKitDynamics/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### 一篇文章学会使用UIKit Dynamics
2+
3+
动力项(UIDynamicItem)是任何遵守`UIDynamicItem`协议的对象,相当于现实世界中的一个基本物体。自iOS 7开始,`UIView``UICollectionViewLayoutAttributes`默认实现了上述协议,你也可以自行实现该协议以便在自定义的类中使用动力效果动画(UIDynamicAnimator),但很少需要这样做。
4+
5+
动力行为(UIDynamicBehavior)为动力项(UIDynamicItem)提供不同的2D物理动画,即指定`UIDynamicItem`应该如何运动、适用哪些物理规则。在这里`UIDynamicBehavior`类似一个抽象类,没有实现具体行为,因此一般使用这个类的子类来对一组`UIDynamicItem`应遵守的行为规则进行描述。`UIDynamicBehavior`可以独立作用,多个动力行为同时作用时遵守力的合成。
6+
7+
UIKit Dynamics库的核心在于`UIDynamicAnimator`,其封装了底层iOS物理引擎,是动力行为(UIDynamicBehavior)的容器,动力行为添加到容器内才会发挥作用,为动力项(UIDynamicItem)提供物理相关的功能和动画。
8+
9+
使用动力学(dynamics)的步骤是:配置一个或多个`UIDynamicBehavior`,其中为每个`UIDynamicBehavior`指定一个或多个`UIDynamicItem`,最后添加这些`UIDynamicBehavior``UIDynamicAnimator`
10+
11+
在这个demo中,使用了UIGravityBehavior、UICollisionBehavior、UIPushBehavior、UIAttachmentBehavior、UISnapBehavior、UIFieldBehavior六种动力行为,详细介绍查看下面文章:
12+
13+
<https://github.com/pro648/tips/wiki/一篇文章学会使用UIKit-Dynamics>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<!--
4+
.xcodeSampleCode.plist
5+
RegularExpression
6+
7+
Created by ad on 25/12/2017.
8+
Copyright (c) 2017 ___ORGANIZATIONNAME___. All rights reserved.
9+
-->
10+
<plist version="1.0">
11+
<dict>
12+
13+
</dict>
14+
</plist>

UIKitDynamics/UIKitDynamics.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
60BFE04E1EFBB18C0026923A /* FifthViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FifthViewController.m; sourceTree = "<group>"; };
5656
60BFE0501EFBB23A0026923A /* TabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabBarController.h; sourceTree = "<group>"; };
5757
60BFE0511EFBB23A0026923A /* TabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabBarController.m; sourceTree = "<group>"; };
58+
60CCE3F21FF293A7005A8FCA /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
5859
/* End PBXFileReference section */
5960

6061
/* Begin PBXFrameworksBuildPhase section */
@@ -78,6 +79,7 @@
7879
60BFE0101EFB98950026923A = {
7980
isa = PBXGroup;
8081
children = (
82+
60CCE3F21FF293A7005A8FCA /* README.md */,
8183
60BFE01B1EFB98960026923A /* UIKitDynamics */,
8284
60BFE0351EFB98960026923A /* UIKitDynamicsTests */,
8385
60BFE01A1EFB98960026923A /* Products */,

UIKitDynamics/UIKitDynamics/SecondViewController.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
110110
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
111111
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath];
112112

113-
if (cell==nil) {
114-
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
115-
}
116-
117113
cell.textLabel.text = [NSString stringWithFormat:@"Option %li",indexPath.row + 1];
118114
cell.textLabel.textColor = [UIColor lightGrayColor];
119115
cell.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

0 commit comments

Comments
 (0)