关于iOS中的颜色
来源:互联网 发布:java spilt 正则 编辑:程序博客网 时间:2024/05/16 10:16
宏定义颜色设置方法
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]// 获取RGB颜色#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]#define RGB(r,g,b) RGBA(r,g,b,1.0f)//我自己感觉的一些比较好看的颜色:#define SoftColorWhite [UIColor whiteColor]#define SoftColorYellow RGB(255, 198, 57) //淡黄色#define SoftColorBlue RGB(73, 133, 234)#define SoftColorGreen RGB(143, 208, 79)#define SoftColorPurple RGB(254, 243, 155)#define SoftColorRed RGB(250, 86, 60)#define SoftColorGray RGB(193, 197, 209)#define PaperColor PaperColorWhite#define PaperBackgroundColor RGB(193, 197, 209)
获取图片某像素点颜色的方法(为UIImage添加扩展方法):
- (UIColor *)colorAtPixel:(CGPoint)point { // Cancel if point is outside image coordinates if (!CGRectContainsPoint(CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), point)) { return nil; } NSInteger pointX = trunc(point.x); NSInteger pointY = trunc(point.y); CGImageRef cgImage = self.CGImage; NSUInteger width = self.size.width; NSUInteger height = self.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); int bytesPerPixel = 4; int bytesPerRow = bytesPerPixel * 1; NSUInteger bitsPerComponent = 8; unsigned char pixelData[4] = { 0, 0, 0, 0 }; CGContextRef context = CGBitmapContextCreate(pixelData,1, 1,bitsPerComponent,bytesPerRow, colorSpace,kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); CGContextSetBlendMode(context, kCGBlendModeCopy); // Draw the pixel we are interested in onto the bitmap context CGContextTranslateCTM(context, -pointX, pointY-(CGFloat)height); CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, (CGFloat)width, (CGFloat)height), cgImage); CGContextRelease(context); // Convert color values [0..255] to floats [0.0..1.0] CGFloat red = (CGFloat)pixelData[0] / 255.0f; CGFloat green = (CGFloat)pixelData[1] / 255.0f; CGFloat blue = (CGFloat)pixelData[2] / 255.0f; CGFloat alpha = (CGFloat)pixelData[3] / 255.0f; return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];}
由于是个人开发者,所以UI设计比较头疼
一些看着比较舒服的颜色的RGB值
0 0
- 关于iOS中的颜色
- iOS中的颜色
- IOS中的RGB颜色值
- IOS中的RGB颜色值
- 关于VS2013中的字体颜色
- 关于ios颜色渐进的总结
- 关于ios颜色渐进的总结
- 关于ios颜色渐进的总结
- 关于ios颜色渐进的总结
- iOS中关于颜色常用的宏
- 关于ios颜色渐进的总结
- 关于ios颜色渐进的总结
- iOS 关于placeholder字体,颜色问题
- 关于ios的切图颜色处理
- iOS 关于颜色的库 - Wonderful
- iOS关于cell点击更换背景颜色
- iOS - Swift 关于颜色的一些方法
- 关于iOS中的NSURLSession
- CodeForces 731 D.80-th Level Archeology(水~)
- 贪心算法-活动安排问题
- Javascript基础学习(一)
- 2017 实习生 阿里巴巴 java笔试题 逆波兰表达式
- C++万能头文件
- 关于iOS中的颜色
- 插入排序算法的简单实现
- 用虚拟机来搭建真实的DOS环境。
- html5 <script> async和defer
- JS数组 学习笔记
- Python使用UUID库生成唯一ID
- 南阳理工acm16矩形嵌套
- npm 安装angular-cli
- CentOS下支持挂载exFAT与NTFS文件系统