• 实现一个view从顶部移到底部的动画 and 将RGB值转化为颜色





    @interface TimingCurveViewController : UIViewController {
      IBOutlet UIImageView *basketBall;
    }


    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

      [UIView beginAnimations:@"movement" context:nil];
      [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; //<label id="code.timingcurve.easeIn"/>
      [UIView setAnimationDuration:1.0f];
      [UIView setAnimationRepeatCount:3];
      [UIView setAnimationRepeatAutoreverses:YES];
      CGPoint center = basketBall.center;
      if(center.y > 85.0f) {
        center.y -= 295.0f;
        basketBall.center = center;
      } else {
        center.y += 295.0f;
        basketBall.center = center;
      }
      [UIView commitAnimations];

    }




    - (void)viewDidLoad{
        [super viewDidLoad];
        self.view.backgroundColor = [self colorWithRGBHexString:@"#abcdef"];
    }


    - (UIColor *)colorWithRGBHexString:(NSString *)rgbColor{
        NSString *cString = rgbColor;
        
        //去除空格并大写NSCharacterSetwhitespaceAndNewlineCharacterSet
        
        cString = [[cString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
        
        if ([cString length] < 6) {
            
            //返回默认颜色
            
            return [UIColor redColor];
            
        }
        
        if ([cString hasPrefix:@"0x"]) {
            
            cString = [cString substringFromIndex:2];
            
        }else if ([cString hasPrefix:@"#"]){
            
            cString = [cString substringFromIndex:1];
            
        }
        
        if ([cString length] != 6) {
            
            //返回默认颜色
            
            return [UIColor redColor];
            
        }
        
        NSRange range;
        
        range.length = 2;
        
        range.location = 0;
        
        NSString *rString = [cString substringWithRange:range];
        
        range.location = 2;
        
        NSString *gString = [cString substringWithRange:range];
        
        range.location = 4;
        
        NSString *bString = [cString substringWithRange:range];
        
        
        
        unsigned int r,g,b;
        
        [[NSScanner scannerWithString:rString] scanHexInt:&r];
        
        [[NSScanner scannerWithString:gString] scanHexInt:&g];
        
        [[NSScanner scannerWithString:bString] scanHexInt:&b];
        
        
        
        return [UIColor colorWithRed:(float)r/255.0 green:(float)g/255.0 blue:(float)b/255.0 alpha:1.0f];
    }

  • 相关阅读:
    月亮,还是馅饼(2)
    月亮,还是馅饼(1)
    spread 论坛
    kaok website
    提升 .NET 程序性能的 一些 原则
    sql convert
    sql 中 MSDTC 不可用。
    判断sql执行所花的时间(精度为毫秒)
    35岁以前成功的12条黄金法则
    快速删除表中的数据
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3089632.html
Copyright © 2020-2023  润新知