iOS 选择头像后显示到imageView中 纯代码

来源:互联网 发布:mac卸载opera 编辑:程序博客网 时间:2024/06/04 21:11

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    //self.headIV.backgroundColor = [UIColor redColor];
    
    UIImageView*iv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 80,80)];

//self.iv = iv 必须选择,不然无法选择到图像
    self.iv = iv;
    iv.layer.borderWidth = 3;
    iv.layer.borderColor = [UIColor blackColor].CGColor;
    iv.userInteractionEnabled = YES;
    UITapGestureRecognizer*tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    tap.numberOfTapsRequired = 1;
    tap.numberOfTouchesRequired = 1;
  
    [iv addGestureRecognizer:tap];
    [self.view addSubview:iv];
    //[self.view addGestureRecognizer:tap];
}

0 0