首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UISegmentedControl定制

UISegmentedControl定制
EN

Stack Overflow用户
提问于 2010-08-12 14:16:45
回答 2查看 961关注 0票数 0

我的一个页面上有一个UISegmentedControl。我想要一个编辑框,当一个片段被点击时,被点击的片段的正下方。我希望它是动画的(幻灯片之类的)

这个是可能的吗?做这件事最好的方法是什么?

见鬼,我忘了提到所有这些动作都将发生在一个单元格中,而不是一个简单的视图中。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-08-12 15:40:09

您可以尝试UIView动画。首先设置您的编辑框(我猜是UITextView ??)到x坐标320 (这样它就不会出现)。其次,当用户点击分段控件时,只需使用UIView动画转换您的UITextView:

代码语言:javascript
复制
[UIView beginAnimation:nil context:nil];
[UIView setAnimationDuration: 1.0];
CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0);
self.view.transform = trans;
[UIView commitAnimations];

希望它能帮助你;)。

票数 1
EN

Stack Overflow用户

发布于 2010-08-12 17:56:01

好的,我会试着说得更准确些,我猜你是在使用Interface Builder吧?所以你必须将一个动作“链接”到你的UISegmentedController,所以在你的类中编写这个方法:

代码语言:javascript
复制
-(IBAction) translateMyView
{
  //If the first segment is selected do translation of the cellView
  if(yourSegmentedController.selectedSegmentIndex == 0)
  {
    [UIView beginAnimation:nil context:nil];
    [UIView setAnimationDuration: 1.0];
    //This will translate the view to its position from its position -320 px
    CGAffineTransform trans = CGAffineTransformMakeTranslation(-320, 0);
    //Replace self.view with the view you want to translate.
    self.view.transform = trans;
    [UIView commitAnimations];
  }
  else if(yourSegementedController.selectedSegmentIndex ==1)
  {
    //Do same thing that above but with another view
  }
}

因此,这就是在segmentedController中选择索引时所发生的操作。您需要做的是将此操作链接到接口生成器中的UISegmentedController。

希望对您有所帮助;-)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3465157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档