七彩霓虹灯能够实现两种效果(更新版本号2)

Posted jzdwajue

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了七彩霓虹灯能够实现两种效果(更新版本号2)相关的知识,希望对你有一定的参考价值。

版本号二效果图;(含应用图标)(此代码临时不显示应用图标,假设须要源代码,email:[email protected])

技术分享

版本号一效果图:

技术分享


//  MHTAppDelegate.h

//  NeonLamp

//  Copyright (c) 2014 Summer. All rights reserved.


#import<UIKit/UIKit.h>

@interface MHTAppDelegate :UIResponder <UIApplicationDelegate>

@property (retain,nonatomic) UIWindow *window;

@end




//  MHTAppDelegate.m

//NeonLamp

//  Copyright (c) 2014 Summer. All rights reserved.


#import "MHTAppDelegate.h"

@interface MHTAppDelegate()

{

    UIView *_containerView;

    UIView *_toOutsideView;

    UIView *_toInsideView;

    UIView *_otherView;

    UIView *_view;

    NSArray *_color;

    NSTimer *_timer;

}

@end

@implementation MHTAppDelegate


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

{

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

    // Override point for customization after application launch.

    

    

    

    _color = [NSArray arrayWithObjects:[UIColor redColor], [UIColor orangeColor], [UIColor yellowColor], [UIColor greenColor], [UIColor blueColor], [UIColor cyanColor], [UIColor purpleColor], nil];

    //创建背景画布

    _containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

    _containerView.backgroundColor = [UIColor clearColor];

    [self.window addSubview:_containerView];

    [_containerView release];

    

    _toOutsideView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

    _toOutsideView.backgroundColor = [UIColor clearColor];

    [_containerView addSubview:_toOutsideView];

    _toOutsideView.tag = 100;

    [_toOutsideView release];

    

    _toInsideView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

    _toInsideView.backgroundColor = [UIColor clearColor];

    [_containerView addSubview:_toInsideView];

    _toInsideView.tag = 101;

    [_toInsideView release];

    

    

    [self toIN];

    [self toOUT];

    [self but];

    [self Line];

    

    

    _timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(click) userInfo:nil repeats:YES];

    

    

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window makeKeyAndVisible];

    return YES;

}

- (void)toIN

{

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

        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10 + 25 * i, 80 + 25 * i, 300 - (0 + 25 * i) * 2, 300 - (25 * i) * 2)];

        view.backgroundColor = [_color objectAtIndex:i];

        [_toInsideView addSubview:view];

        [view release];

        view.tag = 200 + i;

    }

    NSLog(@"%@", [_toInsideView subviews]);

}


- (void)toOUT

{

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

        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10 + 25 * i, 80 + 25 * i, 300 - (0 + 25 * i) * 2, 300 - (25 * i) * 2)];

        view.backgroundColor = [_color objectAtIndex:i];

        [_toOutsideView addSubview:view];

        [view release];

        view.tag = 200 + i;

    }

    NSLog(@"%@", [_toOutsideView subviews]);

}

- (void)but

{

    UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];

    but.frame = CGRectMake(10, 390, 300, 40);

    [but setTitle:@"      " forState:UIControlStateNormal];

    but.titleLabel.font = [UIFont fontWithName:@"EuphemiaUCAS" size:20 ];

    [but setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    but.backgroundColor = [UIColor yellowColor];

    but.layer.cornerRadius = 5;

    but.layer.borderWidth = 1;

    but.layer.borderColor = [[UIColor blueColor] CGColor];

    [but addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];

    [_containerView addSubview:but];

    but.tag = 104;

}

- (void)butClick:(UIButton *)but

{

    [_containerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}

- (void)click

{

    //由里向外

    UIView *temp = [[UIView alloc] init];

    temp.backgroundColor = [_toOutsideView viewWithTag:200].backgroundColor;

    for (int i = 200; i < 206; i++) {

        [_toOutsideView viewWithTag:i].backgroundColor = [_toOutsideView viewWithTag: i + 1].backgroundColor;

    }

    [_toOutsideView viewWithTag:206].backgroundColor =temp.backgroundColor;

    [temp release];

    //由外向里

    UIView *temp1 = [[UIView alloc] init];

    temp1.backgroundColor = [_toInsideView viewWithTag:206].backgroundColor;

    for (int i = 206; i > 200; i--) {

        [_toInsideView viewWithTag:i].backgroundColor = [_toInsideView viewWithTag:i - 1].backgroundColor;

    }

    [_toInsideView viewWithTag:200].backgroundColor = temp1.backgroundColor;

    [temp1 release];

    

}

- (void)Line

{

    //设置切割线

    UILabel *hintLine = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 290, 2)];

    hintLine.backgroundColor = [UIColor grayColor];

    hintLine.layer.cornerRadius = 5;

    hintLine.layer.masksToBounds = YES;

    [_containerView addSubview:hintLine];

    [hintLine release];

    //设置功能的提示内容

    UILabel *hintLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 35, 290, 20)];

    hintLable.textAlignment = NSTextAlignmentCenter;

    hintLable.text = @"Neon effect chart:";

    hintLable.font = [UIFont fontWithName:@"AlNile" size:12];

    [_containerView addSubview:hintLable];

    [hintLable release];

    //copyrightLine(版权)

    UILabel *copyrightLine = [[UILabel alloc] initWithFrame:CGRectMake(10, 470, 300, 2)];

    copyrightLine.backgroundColor = [UIColor grayColor];

    copyrightLine.layer.cornerRadius = 5;

    copyrightLine.layer.masksToBounds = YES;

    [_containerView addSubview:copyrightLine];

    [copyrightLine release];

    UILabel *copyrightLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 440, 290, 15)];

    copyrightLable.textAlignment = NSTextAlignmentCenter;

    copyrightLable.text = @"Copyright ? 2014 summer";

    copyrightLable.font = [UIFont fontWithName:@"AppleSDGothicNeo-Thin" size:12];

    [_containerView addSubview:copyrightLable];

    [copyrightLable release];

    UILabel *copyrightLable1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 455, 290, 15)];

    copyrightLable1.textAlignment = NSTextAlignmentCenter;

    copyrightLable1.text = @"[email protected]";

    copyrightLable1.font = [UIFont fontWithName:@"AppleSDGothicNeo-Thin" size:12];

    [_containerView addSubview:copyrightLable1];

    [copyrightLable1 release];

    

}

- (void)applicationWillResignActive:(UIApplication *)application

{

    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}


- (void)applicationDidEnterBackground:(UIApplication *)application

{

    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}


- (void)applicationWillEnterForeground:(UIApplication *)application

{

    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}


- (void)applicationDidBecomeActive:(UIApplication *)application

{

    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}


- (void)applicationWillTerminate:(UIApplication *)application

{

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

- (void)dealloc

{

    self.window = nil;

    [super dealloc];

}

@end















以上是关于七彩霓虹灯能够实现两种效果(更新版本号2)的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 小技巧之霓虹灯文本的「故障」效果的实现

小5聊使用js+css+div布局方式画一棵圣诞树,带闪烁霓虹灯效果

SVG霓虹灯效果

09.霓虹灯加载特效

前端例程20220818:边框跑马霓虹灯效按钮

超简单的魔幻霓虹灯文字特效 html+css