iOSのいくつかのテクニック

2357 ワード

テクニック1:UIButtonのハイライト効果を無効にする方法1:
button.adjustsImageWhenHighlighted = NO;
方法2:Make your UIButton a custom button and then apply a UIImge background to it.It won't highlight or change when pressed
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

テクニック2:UItableViewCellのハイライトを無効にするには、イベントごとにUItableViewCellのcellを設定することもできます.selectionStyle = UITableViewCellSelectionStyleNone;
テクニック3:UIN avigationViewControlのback buttonのtitle
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
を削除する
テクニック3:ナビゲーションバーのタイトルのフォントを変更するのはiOS 6と同じで、ナビゲーションバーのtitleTextAttributesプロパティを使用してナビゲーションバーの文字スタイルをカスタマイズすることができます.text attributes辞書では、フォント、文字色、文字シャドウ色および文字シャドウオフセットを指定するキーを使用します.ナビゲーションバーのタイトルスタイルを変更しました:

NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
shadow, NSShadowAttributeName,
[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];
テクニック4:iOS releaseバージョンでNSLog出力
 
 

ifndef OPTIMIZE

define NSLog(...) NSLog(VA_ARGS)

else

define NSLog(...) {}

endif

を削除
テクニック5:titleと画像を左右に並べ、デフォルトでは画像が左、文字が右

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, CGRectGetWidth(self.view.frame)/3, 50)];
[button setTitle:@" " forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
UIImage *image = [UIImage imageNamed:@"icon_filter_gray"];
[self.view addSubview:button]; を にしたい は、 を に、

button.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
のコードを できます.