ale*_*ine 15 iphone uiviewanimation ios
我有一个包含两个UIButtons的UIview.
-(void)ViewDidLoad
{
geopointView = [[UIView alloc] initWithFrame:CGRectMake(0, 350, 120, 80)];
geopointView.backgroundColor = [UIColor greenColor];
UIButton *showGeoPointButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
showGeoPointButton.frame = CGRectMake(0, 0, 120, 40);
showGeoPointButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
[showGeoPointButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[showGeoPointButton addTarget:self action:@selector(showPlaces:) forControlEvents:UIControlEventTouchUpInside];
UIButton *SaveButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]
SaveButton.frame = CGRectMake(0, 40, 120, 40);
SaveButton.titleLabel.font = [UIFont systemFontOfSize: 15.0];
[SaveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[SaveButton addTarget:self action:@selector(savePlacePopUp) forControlEvents:UIControlEventTouchUpInside];
[geopointView addSubview:showGeoPointButton];
[geopointView addSubview:SaveButton];
}
Run Code Online (Sandbox Code Playgroud)
我想在调用以下方法时为UIview中的幻灯片设置动画.
-(void) showAnimation
Run Code Online (Sandbox Code Playgroud)
我试着通过以下方式来做,但我看不到动画.我该怎么做?
-(void) showAnimation{
[UIView animateWithDuration:10.0 animations:^{
[self.view addSubview:geopointView];
}];
}
Run Code Online (Sandbox Code Playgroud)
提前获得任何帮助.
Ada*_*ach 60
您需要使用帧值添加子视图,该值是您希望动画开始的地方(屏幕外?),然后更改动画块内的帧值.框架将在持续时间内发生变化,从而导致运动的出现.视图必须已经是一个子视图 - 我不相信添加一个子视图是你可以动画的东西,这是没有意义的.
-(void)showAnimation {
[self.view addSubview:geopointView]
geopointView.frame = // somewhere offscreen, in the direction you want it to appear from
[UIView animateWithDuration:10.0
animations:^{
geopointView.frame = // its final location
}];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30880 次 |
| 最近记录: |