【问题标题】:Translating a UIButton翻译 UIButton
【发布时间】:2011-04-11 01:08:17
【问题描述】:

我想问一下UIButton位置可以翻译吗?

怎么样?有人吗?

【问题讨论】:

    标签: iphone objective-c ios4


    【解决方案1】:

    您可以使用“frame”属性获取按钮的框架。这将返回一个 CGRect 对象,它基本上具有您的按钮 x 坐标、y 坐标、宽度和高度。

    根据您要翻译按钮的位置,计算新的 x 坐标和 y 坐标。 然后执行以下操作:

    btnMyButton.frame = CGRectMake(oldx,oldy,width,height);
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:btnMyButton];
    [UIView setAnimationDuration:0.3];  
    btnMyButton.frame = CGRectMake(newx, newy, width, height);
    [UIView commitAnimations];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-18
      • 2011-12-26
      • 2015-05-19
      • 1970-01-01
      相关资源
      最近更新 更多