iOS Developerios实用开发技巧

解决页面跳转时,搜索条闪烁的问题

2016-11-23  本文已影响424人  Mrxiaowang

当搜索条为导航条的titleView时,页面跳转会造成闪烁的问题,以下为解决办法,直接附代码:

float version = [[[ UIDevice currentDevice ] systemVersion ] floatValue ];

if ([ self.searchBar respondsToSelector : @selector (barTintColor)]) {

float  iosversion7_1 = 7.1 ;

if (version >= iosversion7_1)

{

//iOS7.1

[[[[ self.searchBar.subviews objectAtIndex : 0 ] subviews ] objectAtIndex : 0 ] removeFromSuperview ];

[ self.searchBar setBackgroundColor :[ UIColor clearColor ]];

}

else

{

//iOS7.0

[ self.searchBar setBarTintColor :[ UIColor clearColor ]];

[ self.searchBar setBackgroundColor :[ UIColor clearColor ]];

}

}

else

{

//iOS7.0 以下

[[ self.searchBar.subviews objectAtIndex : 0 ] removeFromSuperview ];

[ self.searchBar setBackgroundColor :[ UIColor clearColor ]];

}

上一篇下一篇

猜你喜欢

热点阅读