1.一个倒影小程序,图像处理不是很理解,记一下用到的:
//获取一个渐变图像
-(CGImageRef)createGradientImage:(int)pixlswide Height:(int)pixlshigh{
CGImageRef cgimage = NULL;
CGColorSpaceRef space = CGColorSpaceCreateDeviceGray();
CGContextRef gradientBitmapContext = CGBitmapContextCreate(NULL, pixlswide, pixlshigh, 8, 0, space, 0);
//定义开始和结束的灰色值
CGFloat colors[] = {0,1,1,1};
CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(space, colors, NULL, 2);
CGColorSpaceRelease(space);
//创建梯度向量的开始和结束点
CGPoint gradientStartPoint = CGPointZero ;
CGPoint gradientEntPoint = CGPointMake(0, pixlshigh);
//绘制渐变为灰度的位图上下文
CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint, gradientEntPoint, kCGGradientDrawsAfterEndLocation);
CGGradientRelease(grayScaleGradient);
cgimage = CGBitmapContextCreateImage(gradientBitmapContext);
CGContextRelease(gradientBitmapContext);
return cgimage ;
}
以上为创建渐变图像,CGColorSpaceRef -> CGContextRef = CGBitmapContextCreate 创建位图上下文 -> CGGradientRef 渐变引用(做什么的?)->CGContextDrawLineearGradient 绘制渐变为灰度的位图上下文
xxxRef类型都要释放 :CGcontextRelease
//创建并获取一个位图上下文
-(CGContextRef)MyCreateBitmapContext:(int) pixelswide Height:(int)pixlshigh{
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();//创建色彩空间
CGContextRef bitmapContext = CGBitmapContextCreate(NULL, pixelswide, pixlshigh, 8, 0, space, kCGBitmapByteOrder32Little);
CGColorSpaceRelease(space);
return bitmapContext;
}
2.缩放移动
缩放用CGAffineTransform CGAffineTransformMakeScale
移动用CGAffineTransform CGAffineTransformMakeTranslation
- pickerview
需要实现代理和数据源方法
-(UIView )pickerView:(UIPickerView )pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
每列显示什么,但是测试时 显示图片有问题
4.viewDidAppear viewDidLoad
前者是图显示后调用,加载xib会调用一次,但是在视图加子视图 addSubview 不会自动调用,需要我们显示调用
另外push视图 也不会调用viewDidAppear ,对UIProGress进行自定义可以在这里加方法
viewDidLoad loadView 下次总结区别。