Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
787 views
in Technique[技术] by (71.8m points)

ios - Can't animate the frame or bounds of a UISearchBar

I want to animate the position of a UISearchBar, but there's no animate effect when I change the frame or bounds property of UISearchBar(center, alpha dose animate).
It's iOS SDK 4.2, is there a bug? I'm confused...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The problem is that some inner search bar views forcing the resize to ignore the animation.

This worked for me -

[UIView animateWithDuration:0.2 animations:^ {
                     [searchBar setFrame:searchBarFrame];
                     [searchBar setNeedsLayout];
                 }];

Where searchBarFrame - is a frame you need to set (I save it before search bar resized first time)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...