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

     

     

  • 相关阅读:
    鼠标移入图片放大效果
    搜索框
    将下拉菜单放入input框中
    轮播图2
    V-demo item.vue
    v-demo1 List.vue
    v-demo1 add.vue
    v-demo1 app.vue
    3D轮播图
    封装代码
  • 原文地址:https://www.cnblogs.com/OIMM/p/4695678.html
Copyright © 2011-2022 走看看