0
我正在使用UIButton来表示放置按钮时向上/向下滑动的表格的栏上的通知数。该按钮的标题动态变化以表示未读取通知的数量。核心动画块中按钮标题动画的值
请参阅附件中的部分屏幕截图。动画
帧开始 - 通知显示为2 - 通知显示为0 - - 动画的正确
帧结束这不应该改变
下面是我使用的动画代码
-(IBAction) showNotifications {
if (notificationTableIsUp) {
CGRect notificationsHeaderFrame = notificationsHeader.frame;
CGRect notificationsTableFrame = notificationsTable.frame;
// Animate to pull up Notification Table
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
notificationTableIsUp = !notificationTableIsUp;
notificationsHeaderFrame.origin.y += 220;
notificationsHeader.frame = notificationsHeaderFrame;
notificationsTableFrame.origin.y += 220;
notificationsTable.frame = notificationsTableFrame;
[UIView commitAnimations];
} else {
CGRect notificationsHeaderFrame = notificationsHeader.frame;
CGRect notificationsTableFrame = notificationsTable.frame;
// Animate to pull down Notification Table
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
notificationTableIsUp = !notificationTableIsUp;
notificationsHeaderFrame.origin.y -= 220;
notificationsHeader.frame = notificationsHeaderFrame;
notificationsTableFrame.origin.y -= 220;
notificationsTable.frame = notificationsTableFrame;
[UIView commitAnimations];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
notificationTableIsUp = NO;
[self updateNotificationBadgeTo:2];
}
- (void) updateNotificationBadgeTo:(NSInteger)numberOfNotifications {
notificationBadgeButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
notificationBadgeButton.titleLabel.textColor = [UIColor whiteColor];
notificationBadgeButton.titleLabel.text = [NSString stringWithFormat:@"%d", numberOfNotifications];
}
注意绿色条是一个UIView和通知是一个UILabel和圆形按钮是一个UIButton都在我成立B. 0是在IB中设置的按钮的初始标题。我在viewDidLoad中将它设置为2。
所以基本的问题是,当我点击按钮,它从白色2(在viewDidLoad中设置)更改为蓝色0(在IB中设置)的值。
当我向上/向下滑动幻灯片时,如何删除此部分?
谢谢 Dev。