要求:
我想用户注册封面照片。所以我想报道像Facebook这样的照片。
我的问题:
2)当我在封面照片上设置图像时,它会自我伸展,不应该拉伸..
3)用户应该可以使用滚动或手势进行调整。
请帮帮我..
答案 0 :(得分:1)
实现目标的最佳途径是:
步骤1:将您的Imageview放在具有相同ImageView框架的一个视图中。
第2步:设置图像内容模式& userInteractionEnabled
YourImageView.contentMode=UIViewContentModeScaleAspectFill;
YourImageView.userInteractionEnabled=YES;
第3步:宣布Pan Gesture
@property (strong, nonatomic) UIPanGestureRecognizer *panGesture;
步骤4:定义PanGesture以及分配YourImageview。
self.panGesture=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureComplete:)];
[YourImageView addGestureRecognizer:self.panGesture];
<强>(更新)强> 第5步:添加以下方法..
-(void)panGestureComplete : (UIPanGestureRecognizer *)parameter{
if (parameter.state != UIGestureRecognizerStateEnded && parameter.state != UIGestureRecognizerStateFailed) {
CGPoint point=[parameter locationInView:parameter.view.superview];
// _ViewContainer is the View in which image lies..
if ( CGRectContainsPoint(_ViewContainer.bounds, point) ) {
// Point lies inside the your view Container bounds.
CGPoint pntTemp=_imgView.center;
pntTemp.y=point.y;
parameter.view.center=pntTemp;
}
}
}
你完成了...... 希望这有助于.. :))