//圆角头像 UIImageView _avatarView = new UIImageView(new RectangleF(_blockSpace, _blockSpace, 2 * _avatarRadius, 2 * _avatarRadius)); UIImage img= UIImage.FromFile("profile-pic.jpg"); _avatarView.Layer.Contents =img.CGImage; _avatarView.Layer.MasksToBounds = true;//如果没有将MasksToBounds设置为true,图片设置CornerRadius圆角无效↓ _avatarView.Layer.CornerRadius = _avatarRadius; _avatarView.UserInteractionEnabled = true;//用户互动属性,设置为true时才会触发点击事件 _avatarView.AddGestureRecognizer(new UITapGestureRecognizer(()=>{Console.WriteLine("图片被点击了");}));