処理中を示すビューをつくる(iOS)
以前Android で似たような投稿をしましたが, iOSでも何かの処理中もしくは, 関係のないUIを触らせないようにするために,
影のかかったようなViewを作ります。
+(UIView *)makeShadowWithTag:(float)x y:(float)y width:(float)width height:(float)height tag:(int)tag { UIView *shadow = [[UIView alloc] initWithFrame:CGRectMake(x, y, width, height)]; shadow.tag = tag; shadow.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5 ]; return shadow; } +(void)removeViewWithTag:(int)tag view:(UIView *)view { for ( UIView *tmp in view.subviews ) { if ( tmp.tag == tag ) { [tmp removeFromSuperview]; } } }
関数としてまとめてみました。makeShadowWithTag という関数で, 縦横の大きさおよび, このViewのタグをつけます。
UiViewを作って, background に透明の入ったViewをつくって, それを親View に重ねます。これで下のUIにはタッチできません。
これをはずすときは, 先ほど作成のときにつけたタグをもとに検索して, このViewだけをremoveします。