zoukankan      html  css  js  c++  java
  • 圆形跑马灯


     

     

     

    #import <UIKit/UIKit.h>

     

    @interface AppDelegate : UIResponder <UIApplicationDelegate>

    {

        int k;

    }

    @property (strong, nonatomic) UIWindow *window;

     

     

    @end

    #import "AppDelegate.h"

    @interface AppDelegate ()

    @end

    @implementation AppDelegate

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        

        //[UIScreen mainScreen].bounds获取硬件设备的屏幕尺寸

        //backgroundColor 背景颜色

        //makeKeyAndVisible 让当前窗口展示在最前端

        

        self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

        self.window.backgroundColor=[UIColor whiteColor];

        [self.window makeKeyAndVisible];

        

        

        int x=20,y=40,l=280;

        NSMutableArray *array=[NSMutableArray arrayWithObjects:[UIColor redColor],[UIColor orangeColor],[UIColor yellowColor],[UIColor greenColor],[UIColor blueColor],[UIColor cyanColor],[UIColor purpleColor], nil];

        for (int i=0; i<7; i++) {

            UIView *view=[[UIView alloc]initWithFrame:CGRectMake(x, y, l, l)];

            view.tag=i+100;

            view.backgroundColor=[array objectAtIndex:i];

            

            

            view.layer.masksToBounds = YES;//确定划圆

            view.layer.cornerRadius = view.frame.size.width/2;//确定半径

            [self.window addSubview:view];

            x+=20,y+=20,l-=40;

        }

        

        [NSTimer scheduledTimerWithTimeInterval:0.2f target:self selector:@selector(changeColor:) userInfo:array repeats:YES];

         return YES;

    }

    -(void)changeColor:(NSTimer *)timer

    {

        NSMutableArray *colorArray=[timer userInfo];

        [colorArray addObject:[colorArray objectAtIndex:0]];

        [colorArray removeObjectAtIndex:0];

        for (int i=100; i<107; i++) {

            UIView *getView=[self.window viewWithTag:i];

            getView.backgroundColor=[colorArray objectAtIndex:i-100];

        }

        

    }

    @end

     

     

  • 相关阅读:
    PY个树状数组
    PY 个板子计划【雾
    PY个欧拉筛
    【NOI2007】项链工厂 ——老题新做.jpg
    Min-Max 容斥的证明
    51nod 1963 树上Nim
    ●BZOJ 3566 [SHOI2014]概率充电器
    ●BZOJ 3640 JC的小苹果
    ●BZOJ 1444 [Jsoi2009]有趣的游戏
    ●Joyoi Dotp 驱逐猪猡
  • 原文地址:https://www.cnblogs.com/OIMM/p/4695678.html
Copyright © 2011-2022 走看看