左側で前後にスライドする別の uiview の上に積み重ねられた uiview があります。右側にスライドさせるには、どうすれば反転できますか?私が使用しているコードは次のとおりです。
//Slides Left
- (IBAction) panLayer:(UIPanGestureRecognizer *)pan {
if (pan.state == UIGestureRecognizerStateChanged) {
CGPoint point = [pan translationInView:self.topLayer];
CGRect frame = self.topLayer.frame;
frame.origin.x = self.layerPosition +point.x;
if (frame.origin.x < 0) frame.origin.x = 0;
self.topLayer.frame = frame;
}
if (pan.state ==UIGestureRecognizerStateEnded) {
if (self.topLayer.frame.origin.x <= 160) {
[self animateLayerToPoint:0];
} else {
[self animateLayerToPoint:VIEW_HIDDEN];
}
}
}
// Slides right
- (IBAction)panLayerRight:(UIPanGestureRecognizer *)pan2
{
if(pan2.state == UIGestureRecognizerStateChanged)
{
CGPoint point = [pan2 translationInView:topLayer];
CGRect frame = topLayer.frame;
frame.origin.x = layerPosition + point.x;
if(frame.origin.x + 320 > 320) frame.origin.x = 0;
topLayer.frame = frame;
}
if (pan2.state == UIGestureRecognizerStateEnded) {
if (topLayer.frame.origin.x +320 <= 260) {
[self animateLayerToPoint2:-180];
}
else
{
[self animateLayerToPoint2:VIEW_HIDDEN];
}
}
}
-(void) animateLayerToPoint:(CGFloat)x
{
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
CGRect frame = self.topLayer.frame;
frame.origin.x = x;
self.topLayer.frame = frame;
}
completion:^(BOOL finished){
self.layerPosition = self.topLayer.frame.origin.x;
}];
}
-(void)animateLayerToPoint2:(CGFloat)x
{
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGRect frame = topLayer.frame;
frame.origin.x = x;
topLayer.frame = frame;
}completion:^(BOOL finished) {
self.layerPosition = topLayer.frame.origin.x;
}];
}