Objective-C Learning Notes - UIImage(坑)
使用 UIImage 显示图片:(通过 UIImage 的方法 drawAtPoint 或者drawInRect)
麻痹又是一段不能用的代码!!!!!@20150211
#@import "UIKitPrjUIImage.h"
//实现 UIView 子类
@implementation DrawImageTest
- (id)initWithImage:(UIImage *)image{
if ((self = [super init])){
myImage = image;
}
return self;
}
- (void)drawRect:(CGRect)rect{
// 切换 drawAtPoint 与 drawInRect
[myImage drawAtPoint:rect.origin];
// [myImage drawInRect:rect];
}
- (void)viewDidLoad {
[super viewDidLoad];
//读入文件
myImage = [UIImage imageNamed:@"0.jpg"];
//创建定制的 View
DrawImageTest *test = [[ViewController alloc]initWithImage:myImage];
test.frame = self.view.bounds;
test.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:test];
// Do any additional setup after loading the view, typically from a nib.
}
@end