【问题标题】:How to animate UISearchbar frame change keeping the rounded caps?如何为 UISearchbar 框架更改设置动画以保持圆角大写?
【发布时间】:2013-03-15 19:00:07
【问题描述】:

我想为 UISearchbar 的框架变化设置动画。我希望它在点击搜索按钮时展开和折叠。

我正在使用UIViewAnimationBlock 制作动画

[UIView animateWithDuration:0.5
                              delay:0
                            options:UIViewAnimationOptionLayoutSubviews
                         animations:^{
                             //Set the frame you want to the search bar
                         }
                         completion:^(BOOL finished) {

                         }];

我必须从零开始扩展框架并将其折叠回来。但是在制作动画时,搜索栏失去了圆角并变成了一个矩形。这是它的屏幕截图,同时还在制作动画

它看起来不太好。我希望它在展开或折叠时保持圆润的边缘。可能吗 ?如果是怎么办?

任何帮助将不胜感激。

【问题讨论】:

    标签: ios ios5 ios6 uisearchbar uiviewanimation


    【解决方案1】:

    你不能改变 UISearchBar 的高度尝试设置高度为 44px 的框架。

    如果你想改变高度,那么使用 CGAffineTransformMakeScale 之类的......

    //FOR EXPAND USE THIS:
    
    [UIView animateWithDuration:0.5
                                  delay:0
                                options:UIViewAnimationOptionLayoutSubviews
                             animations:^{
                                 self.searchBar.transform = CGAffineTransformMakeScale(1.0, 1.0);
                             }
                             completion:^(BOOL finished) {
    
                             }];
    

    //扩展使用:

    [UIView animateWithDuration:0.5
                                  delay:0
                                options:UIViewAnimationOptionLayoutSubviews
                             animations:^{
                                 self.searchBar.transform = CGAffineTransformMakeScale(0.001, 0.001);
                             }
                             completion:^(BOOL finished) {
    
                             }];
    

    【讨论】:

      猜你喜欢
      • 2015-01-02
      • 1970-01-01
      • 2021-04-13
      • 2019-09-10
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多