#import
"ThirdViewController.h"
@interface ThirdViewController ()<</span>UINavigationControllerDe legate,UIImagePickerControllerD elegate>
@property(nonatomic,strong)UIImageView * imageView;
@end
@implementation ThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.imageView=[[UIImageView alloc]initWithFrame:CGRectMake(50, 100, 300, 300)];
self.imageView.backgroundColor=[[UIColor cyanColor]colorWithAlphaComponent:0.5];
//圆角效果 动画效果没有切角失效
self.imageView.layer.masksToBounds = YES;
//高的一半 切成圆
self.imageView.layer.cornerRadius =self.imageView.frame.size.height/2;
//打开交互
self.imageView.userInteractionEnabled=YES;
[self.view addSubview:self.imageView];
//创建手势
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
[self.imageView addGestureRecognizer:tap];
}
-(void)tapAction{
//点说明看
UIImagePickerController *picker=[UIImagePickerController new];
//设置代理
picker.delegate=self;
//允许编辑
picker.allowsEditing = YES;
//从相册里选 看API说明
picker.sourceType= UIImagePickerControllerS ourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWit hInfo:(NSDictionary<</span>NSString *,id> *)info{
[self dismissViewControllerAni mated:YES completion:^{
UIImage *image=[ info objectForKey:UIImagePickerControllerO riginalImage];
_imageView.image=image;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@interface ThirdViewController ()<</span>UINavigationControllerDe
@property(nonatomic,strong)UIImageView * imageView;
@end
@implementation ThirdViewController
- (void)viewDidLoad {
}
-(void)tapAction{
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWit
}
- (void)didReceiveMemoryWarning {
}
@end