标签:
1 - (void)pan:(UIPanGestureRecognizer *)sender 2 { 3 4 typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) { 5 UIPanGestureRecognizerDirectionUndefined, 6 UIPanGestureRecognizerDirectionUp, 7 UIPanGestureRecognizerDirectionDown, 8 UIPanGestureRecognizerDirectionLeft, 9 UIPanGestureRecognizerDirectionRight 10 }; 11 12 static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined; 13 14 switch (sender.state) { 15 16 case UIGestureRecognizerStateBegan: { 17 18 if (direction == UIPanGestureRecognizerDirectionUndefined) { 19 20 CGPoint velocity = [sender velocityInView:recognizer.view]; 21 22 BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x); 23 24 if (isVerticalGesture) { 25 if (velocity.y > 0) { 26 direction = UIPanGestureRecognizerDirectionDown; 27 } else { 28 direction = UIPanGestureRecognizerDirectionUp; 29 } 30 } 31 32 else { 33 if (velocity.x > 0) { 34 direction = UIPanGestureRecognizerDirectionRight; 35 } else { 36 direction = UIPanGestureRecognizerDirectionLeft; 37 } 38 } 39 } 40 41 break; 42 } 43 44 case UIGestureRecognizerStateChanged: { 45 switch (direction) { 46 case UIPanGestureRecognizerDirectionUp: { 47 [self handleUpwardsGesture:sender]; 48 break; 49 } 50 case UIPanGestureRecognizerDirectionDown: { 51 [self handleDownwardsGesture:sender]; 52 break; 53 } 54 case UIPanGestureRecognizerDirectionLeft: { 55 [self handleLeftGesture:sender]; 56 break; 57 } 58 case UIPanGestureRecognizerDirectionRight: { 59 [self handleRightGesture:sender]; 60 break; 61 } 62 default: { 63 break; 64 } 65 } 66 break; 67 } 68 69 case UIGestureRecognizerStateEnded: { 70 direction = UIPanGestureRecognizerDirectionUndefined; 71 break; 72 } 73 74 default: 75 break; 76 } 77 78 }
1 UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10]; 2 (刚才有人提醒这个已经deprecated了哈,现在的方法叫resizableImageWithCapInsets).
FlipBoard出品的太适合你了。https://github.com/Flipboard/FLAnimatedImage
https://github.com/samvermette/SVPullToRefresh
1 [tableView addPullToRefreshWithActionHandler:^{ 2 // prepend data to dataSource, insert cells at top of table view 3 // call [tableView.pullToRefreshView stopAnimating] when done 4 } position:SVPullToRefreshPositionBottom];
_mTableView.tintColor = [UIColor redColor];
1 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; }
1 [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; self.navigationBar.shadowImage = [UIImage new]; self.navigationBar.translucent = YES;
继承uitextfield,重写这个方法
1 - (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment]; }
去stackoverflow刷问题啊,少年!
标签:
原文地址:http://www.cnblogs.com/myios/p/4191228.html