UIView's Neon light realization

Source: Internet
Author: User

appdelegate.m//nihongpractice//#import "AppDelegate.h" #define Kcolorvalue arc4random_uniform (256)/255.0# Define Kscreenwidth [UIScreen mainscreen].bounds.size.width#define kscreenheight [UIScreen mainScreen].        Bounds.size.height@interface appdelegate () @end @implementation appdelegate-(void) dealloc{Self.window = nil;    [Super Dealloc];    }-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {    Self.window = [[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];    Override point for customization after application launch.    Self.window.backgroundColor = [Uicolor Whitecolor];            [Self.window makekeyandvisible]; for (int i = 0; i < i++) {UIView *view = [[UIView alloc] Initwithframe:cgrectmake (15*i, 15*i, KSCR                eenWidth-30 * I, kScreenHeight-30 * i)]; Range of color values (0~255) View.backgroundcolor = [Uicolor colorwithred:kcolorvalue green:Kcolorvalue Blue:kcolorvalue alpha:1];                View.tag = + i;                [Self.window Addsubview:view];            [View release]; } [Nstimer scheduledtimerwithtimeinterval:0.5 target:self selector: @selector (ChangeColor) Userinfo:nil Repeats:YES];        Every second to call the ChangeColor method, a color conversion//[self ChangeColor]; return YES;}        -(void) ChangeColor {uicolor *color = [Self.window viewwithtag:200 + 10].backgroundcolor; for (int i = ten; I >= 0; i--) {[Self.window viewwithtag:200 + i].backgroundcolor = [Self.window viewwit htag:200 + I-1].backgroundcolor;    The first created tag value is small, and the result is shown as converting color from outward to} [self.window viewwithtag:200].backgroundcolor = color; }

UIView's Neon light realization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.