gpt4 book ai didi

ios - 从右点更改 UISearchBar 宽度

转载 作者:行者123 更新时间:2023-11-29 03:58:17 25 4
gpt4 key购买 nike

我有 UISearchBar,我希望它在点击时展开。我有像这样的动画:

[UISearchBar beginAnimations:nil context:NULL];
[UISearchBar setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UISearchBar setAnimationDuration:0.5];
[self.searchBar setFrame:CGRectMake(self.searchBar.frame.origin.x, self.searchBar.frame.origin.y, self.searchBar.frame.size.width +100, self.searchBar.frame.size.height)];
[UISearchBar commitAnimations];

这是有效的,但它从左到右扩展它,但我希望它从右到左扩展它。我想做一些类似在界面生成器中的操作,您可以从 9 个点中选择 1 个点来扩展。

我尝试设置

[searchBar.layer setAnchorPoint:CGPointMake(1, 0.5)];

但是没有成功。

马可

最佳答案

您可以执行以下操作:

[UIView animateWithDuration:0.5
animations:^{
[UIView animateWithDuration:1.0 animations:^{
self.searchBar.frame = CGRectMake(self.searchBar.frame.origin.x - 50.0f, self.searchBar.frame.origin.y, self.searchBar.frame.size.width + 50.0f, self.searchBar.frame.size.height);
[self.searchBar layoutSubviews];
}];
}
completion:^(BOOL finished){ }];

这将使右侧粘住并看到左侧的生长。

关于ios - 从右点更改 UISearchBar 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16208024/

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