We recommend an iOS color library-Wonderful, ios library-wonderful

Source: Internet
Author: User

We recommend an iOS color library-Wonderful, ios library-wonderful

The Wonderful library is mainly connected to the UIColor information, which contains four sub-Files: UIColor + Wonderful, UIColor + Separate, SXColorGradientView, and SXMarquee. Corresponding to four main functions: Color extension, color separation, color gradient, and marquee.

Project address: https://github.com/dsxNiubility/Wonderful

 

1. UIColor + Wonderful

1. This classification provides more than 100 Color extensions, such as khaki, silver, lawn green, golden, chocolate, and so on. Although this function may not be suitable for enterprise-level apps that have been directly developed with UI specifications, it is useful for some small apps and Demo programs. RedColor buleColor is no longer needed, and colorWithRGB is no longer needed for a special color. As long as this library is introduced, most common colors can be used directly.

    self.view.backgroundColor = [UIColor khakiColor];    self.view.backgroundColor = [UIColor chocolateColor]; 

2. On average, each color system has 10 colors. Not only can the name be directly typed out, but also the macro of the color ladder can be used to make it easier to remember words. Macro from 1 ~ 10 is the color gets deeper, you can use a shallow macro or a deep macro according to your own feelings.

    self.view.backgroundColor = Wonderful_YelloeColor4;    self.view.backgroundColor = Wonderful_BrownColor4;

3. A color fine-tuning scheme is provided to increase or decrease a certain value of rgb of a known color. It can be used for operations such as border 20 deeper than the background regardless of the background color. You can also print the detailed values of the recognized colors.

UIColor * navColor = [[UIColor redColor] up: SXColorTypeBlue num: 30]; // increase the blue color value by 30 on the red color * barColor = [[UIColor blueColor] up: 1 num: 140]; // you can use the corresponding tag UIColor * bgColor = [[UIColor blackColor] down: SXColorTypeAlpha num: 10]. // obtain a color that is a little lighter than black. UIColor * lineColor = [bgColor up: 3 num: 20]; // no matter what the background color line is, the background is 20 lighter than the background.

 

First, let's look at the effect: (gif images may be blurred, but the transition is actually very high-definition)

Ii. UIColor + Separate

1. Provides a color separation scheme to retrieve RGB and alpha values of any color.

    UIColor *testC = [UIColor salmonColor];    float r= [testC red];    float g= [testC green];    float b= [testC blue];    float alpha= [testC alpha];    NSLog(@"******  %f,%f,%f,%f",r,g,b,alpha);

2. You can use a color to calculate the reversed color of this color, so that no matter what color the background is set by the user, the text color is the reversed color of the background.

    self.showLbl1.backgroundColor = [UIColor peachRed];    self.showLbl1.textColor = [[UIColor peachRed]reverseColor];

3. You can also print the detailed values of this color.

[[UIColor salmonColor]printDetail];
// Print the result This Color's Red: 250, Green: 128, Blue: 114, Alpha: 1 decimal red: 0.9804 green: 0.5020 blue: 0.4471 Hexadecimal 0xfa8072
Iii. SXColorGradientView

1. color gradient view, you can set any color to transparent transition. If you are interested, you can set the navigation bar to gradient from top to bottom. Currently, this gradient is basically a background image and cannot be changed. The cost of using the native method to achieve gradient is definitely smaller than that of the image.

    SXColorGradientView *grv1 = [SXColorGradientView createWithColor:[UIColor paleGreen] frame:CGRectMake(10, 10, 80, 30) visible:YES direction:SXColorGradientToRight];

2. You can also set the transition between two colors.

    SXColorGradientView *grv3 = [SXColorGradientView createWithFromColor:[UIColor peruColor] toColor:[UIColor ghostWhite] frame:CGRectMake(10, 50, 80, 30) direction:SXColorGradientToRight];

3. You can set the direction of transition to the upper, lower, and left directions.

typedef NS_ENUM(NSInteger, SXColorGradientDirection) {    SXColorGradientToTop = 1,    SXColorGradientToLeft = 2,    SXColorGradientToBottom = 3,    SXColorGradientToRight = 4,};

* 4. An array will be added later, and a view with multiple color transitions will be created.

 

Iv. SXMarquee

1. currently, there are few projects with a lawn lamp in iOS projects, and Android has its own lawn lamp control. However, for iOS, for various reasons, at least I have not seen projects with a lawn lamp, in fact, this function should be very commonly used and very convenient and meaningful. Currently, there are few third-party libraries for running the horse lights, and most of them have the following problems: the code is too old and complicated to implement. Only the white background can be implemented, click events cannot be bound, and click to pause and drag.

    SXMarquee *mar3 = [[SXMarquee alloc]initWithFrame:CGRectMake(20, 390, 335, 25) speed:2 Msg:@"If you've submitted an update to fix a critical bug in your app on the App Store and you are requesting an expedited review." bgColor:[UIColor goldColor] txtColor:[UIColor goldenrod]];    [mar3 changeMarqueeLabelFont:[UIFont boldSystemFontOfSize:12]];    [mar3 start];

2. Any color can be set for the background of the marquee. This is based on the color transition view.

3. You can drag or bind more click events.

If you do not see this article in Dong Boran's blog, click to view the original article.

Related Article

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.