- (void)pan:(UIPanGestureRecognizer *)sender
{
typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {
UIPanGestureRecognizerDirectionUndefined,
UIPanGestureRecognizerDirectionUp,
UIPanGestureRecognizerDirectionDown,
UIPanGestureRecognizerDirectionLeft,
UIPanGestureRecognizerDirectionRight
};
static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;
switch
(sender.state) {
case
UIGestureRecognizerStateBegan: {
if
(direction == UIPanGestureRecognizerDirectionUndefined) {
CGPoint velocity = [sender velocityInView:recognizer.view];
BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);
if
(isVerticalGesture) {
if
(velocity.y > 0) {
direction = UIPanGestureRecognizerDirectionDown;
}
else
{
direction = UIPanGestureRecognizerDirectionUp;
}
}
else
{
if
(velocity.x > 0) {
direction = UIPanGestureRecognizerDirectionRight;
}
else
{
direction = UIPanGestureRecognizerDirectionLeft;
}
}
}
break
;
}
case
UIGestureRecognizerStateChanged: {
switch
(direction) {
case
UIPanGestureRecognizerDirectionUp: {
[self handleUpwardsGesture:sender];
break
;
}
case
UIPanGestureRecognizerDirectionDown: {
[self handleDownwardsGesture:sender];
break
;
}
case
UIPanGestureRecognizerDirectionLeft: {
[self handleLeftGesture:sender];
break
;
}
case
UIPanGestureRecognizerDirectionRight: {
[self handleRightGesture:sender];
break
;
}
default
: {
break
;
}
}
break
;
}
case
UIGestureRecognizerStateEnded: {
direction = UIPanGestureRecognizerDirectionUndefined;
break
;
}
default
:
break
;
}
}
10
怎么播放GIF的时候这么卡,有没有好点的库?
FlipBoard出品的太适合你了:https://github.com/Flipboard/FLAnimatedImage
11.怎么一句话添加上拉刷新?
https://github.com/samvermette/SVPullToRefresh
1
2
3
4
|
[tableView addPullToRefreshWithActionHandler:^{
} position:SVPullToRefreshPositionBottom];
|
12.怎么把我的navigationbar弄成透明的而不是带模糊的效果?
1
2
3
4
|
[self.navigationBar setBackgroundImage:[UIImage
new
]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage
new
];
self.navigationBar.translucent = YES;
13
|
怎么改变uitextfield placeholder的颜色和位置?
继承uitextfield,重写这个方法
1
2
3
4
|
- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
}
|