gpt4 book ai didi

iphone - 将 UIButton 的文本设置为日期

转载 作者:行者123 更新时间:2023-12-03 21:07:23 27 4
gpt4 key购买 nike

我有一个 UIButton,单击它会弹出一个 UIDatePicker 来设置它的日期。

一切都已设置好,包括动画的进出等。

我需要什么帮助:

默认情况下,将按钮的文本标签设置为当天的日期。然后在 UIDatePicker 关闭后将其设置为新选择的日期。

 - (IBAction)dateButtonPressed
{
[dateView setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:dateView];

[UIView animateWithDuration:.5 animations:^{
[dateView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
}];
}

- (IBAction)dismssPicker
{
[dateView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

[UIView animateWithDuration:.5 animations:^{
[dateView setFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
} completion:^(BOOL finished){ [dateView removeFromSuperview]; }];
}

最佳答案

- (void)setTitle:(NSString *)title forState:(UIControlState)state

更改按钮的文本。

喜欢

[button setTitle:[date description] forState:UIControlStateNormal]

关于iphone - 将 UIButton 的文本设置为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5659330/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com