gpt4 book ai didi

iphone - iPhone中的 subview 动画

转载 作者:行者123 更新时间:2023-12-01 19:23:58 24 4
gpt4 key购买 nike

我正在使用下面的代码来显示隐藏我的 subview :

    [self.view addSubview:selectorView];
[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)];
viewVisible = NO;

- (IBAction)onButtonClick:(id)sender {
[self showHideView]; // Show and hide our imageView in an animated fashion}

- (void)showHideView {
if (viewVisible) { // If our imageView is on screen hide the view
[UIView beginAnimations:@"animateImageOff" context:NULL]; // Begin animation
[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)]; // Move imageView off screen
[UIView commitAnimations]; // End animations
viewVisible = NO;
[showHideButton setTitle:@"Show" forState:UIControlStateNormal]; // Change button title to "Show"
} else { // if our imageView is off screen show the view
[UIView beginAnimations:@"animateImageOn" context:NULL]; // Begin animation
[selectorView setFrame:CGRectOffset([selectorView frame], 0, selectorView.frame.size.height)]; // Move imageView on screen
[UIView commitAnimations]; // End animations
viewVisible = YES;
[showHideButton setTitle:@"Hide" forState:UIControlStateNormal]; // Change button title to "Hide"

}}

如何在此代码中设置 subview Y 轴值,因为当 subview 出现在屏幕上时,它会隐藏我的屏幕标题栏而且我正在使用按钮来显示/隐藏 subview ,我还想为该按钮设置动画,以便当单击按钮,按钮的位置也应沿 Y 轴更改。

这是我想要的截图

enter image description here

enter image description here

最佳答案

尝试将您的标题 View 放在 MainView 的前面:

     [self.view bringSubviewToFront:headerView];

而图像按钮动画你可以这样做:
[UIView animateWithDuration:1.0 animations:^{
CGFloat degrees = 180;
CGAffineTransform transform =
CGAffineTransformMakeRotation(degrees/180 * 3.14);
imageButton.transform = transform;

}];

关于iphone - iPhone中的 subview 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8871698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com