การแปลง iOS และภาพเคลื่อนไหวของเฟรม

ฉันต้องการเปลี่ยนกรอบมุมมองเป็นขอบเขตเต็มหน้าจอและแปลงเป็นแนวนอน

ฉันใช้เฟรมการเปลี่ยนแปลงภาพเคลื่อนไหว UIView และการแปลงมุมมอง

- (void)enterFullScreen {
  CGRect frame = CGRectMake(0, 0, CGRectGetHeight(UIScreen.mainScreen.bounds), CGRectGetWidth(UIScreen.mainScreen.bounds));
  self.originFrame = self.presentView.frame;
  [UIView animateWithDuration:ZXYAnimationDuration animations:^{
    self.presentView.transform = CGAffineTransformMakeRotation(M_PI_2);
    self.presentView.frame = frame;
  } completion:^(BOOL finished) {

  }];
}

- (void)exitFullScreen {
  [UIView animateWithDuration:ZXYAnimationDuration animations:^{
    self.presentView.transform = CGAffineTransformIdentity;
    self.presentView.frame = self.originFrame;
  } completion:^(BOOL finished) {

  }];
}

ฉันคาดว่ามุมมองจะหมุนเป็นแนวนอนและเต็มหน้าจอ แต่ดูเหมือนว่าจะมีข้อผิดพลาดในการหมุน ป้อนคำอธิบายรูปภาพที่นี่


person jacinzhang    schedule 22.08.2019    source แหล่งที่มา
comment
อย่าแก้ไขเฟรมให้ใช้ข้อจำกัด Autolayout แทน   -  person Sheshnath    schedule 23.08.2019
comment
ฉันพบว่าไม่สามารถแก้ไข trasnform และ frame ในเวลาเดียวกันได้ หากฉันแก้ไขเฉพาะ frame หรือ Transform เท่านั้น นั่นก็ทำงานได้ดี   -  person jacinzhang    schedule 23.08.2019


คำตอบ (1)


สุดท้ายผมลองแล้ว คำตอบคือ อย่าเปลี่ยนความกว้างและความสูงเหมือนด้านล่างครับ

- (void)enterFullScreen {
  CGRect frame = CGRectMake(0, 0, CGRectGetWidth(UIScreen.mainScreen.bounds), CGRectGetHeight(UIScreen.mainScreen.bounds));
  self.originFrame = self.presentView.frame;
  [UIView animateWithDuration:ZXYAnimationDuration animations:^{
    self.presentView.transform = CGAffineTransformMakeRotation(M_PI_2);
    self.presentView.frame = frame;
  } completion:^(BOOL finished) {

  }];
}

- (void)exitFullScreen {
  [UIView animateWithDuration:ZXYAnimationDuration animations:^{
    self.presentView.transform = CGAffineTransformIdentity;
    self.presentView.frame = self.originFrame;
  } completion:^(BOOL finished) {

  }];
}
person jacinzhang    schedule 04.09.2019