zoukankan      html  css  js  c++  java
  • iOS开发的一些奇巧淫技2

    能不能只用一个pan手势来代替UISwipegesture的各个方向?

     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). 

    怎么播放GIF的时候这么卡,有没有好点的库?

    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];

    怎么把tableview里cell的小对勾的颜色改成别的颜色?

    _mTableView.tintColor = [UIColor redColor];


     

    本来我的statusbar是lightcontent的,结果用UIImagePickerController会导致我的statusbar的样式变成黑色,怎么办?

    1 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; }

    怎么把我的navigationbar弄成透明的而不是带模糊的效果?

    1 [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; self.navigationBar.shadowImage = [UIImage new]; self.navigationBar.translucent = YES;

    怎么改变uitextfield placeholder的颜色和位置?

    继承uitextfield,重写这个方法

    1 - (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment]; }

    你为什么知道这么多奇怪的花招?

    去stackoverflow刷问题啊,少年!

  • 相关阅读:
    jQuery EasyUI API 中文文档 可调整尺寸
    jQuery EasyUI API 中文文档 链接按钮(LinkButton)
    jQuery EasyUI API 中文文档 手风琴(Accordion)
    jQuery EasyUI API 中文文档 表单(Form)
    jQuery EasyUI API 中文文档 组合(Combo)
    jQuery EasyUI API 中文文档 布局(Layout)
    jQuery EasyUI API 中文文档 拆分按钮(SplitButton)
    jQuery EasyUI API 中文文档 菜单按钮(MenuButton)
    jQuery EasyUI API 中文文档 搜索框
    jQuery EasyUI API 中文文档 验证框(ValidateBox)
  • 原文地址:https://www.cnblogs.com/myios/p/4191228.html
Copyright © 2011-2022 走看看