1.UILabel 换行
1 versionLabel.lineBreakMode = UILineBreakModeWordWrap; 3 versionLabel.numberOfLines = 0;
2.UILabel 阴影
1 tipLabel.shadowColor = [UIColorwhiteColor]; 2 tipLabel.shadowOffset = CGSizeMake(1.0, 1.0);
3.自定义 View 实现drawRect方法
@interface CustomView :UIView @end @implementation CustomView - (void)drawRect:(CGRect)rect { //画长方形 CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(ctx, [RGBCOLOR(213, 213, 213) CGColor]); CGContextSetLineWidth(ctx, 1.0); CGPoint poins[] = {CGPointMake(0, 0),CGPointMake(280, 0),CGPointMake(280, 40),CGPointMake(0, 40)}; CGContextAddLines(ctx,poins,4); CGContextClosePath(ctx); CGContextStrokePath(ctx); //画线 CGContextMoveToPoint(ctx, 195, 0); CGContextAddLineToPoint(ctx, 195, 40); CGContextSetLineWidth(ctx, 1.0); CGContextStrokePath(ctx); } @end
4.复制到剪贴板
1 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 2 pasteboard.string = qqLabel.text;
5.键盘事件
1 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 2 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
实现方法:
#pragma mark - key board notice -(void)keyboardWillShow:(NSNotification*)note { [UIView animateWithDuration:0.3 animations:^(void) { CGRect r = CGRectZero; [[note.userInfo objectForKey:@"UIKeyboardFrameEndUserInfoKey"] getValue:&r]; CGRect rect = contentView.frame; rect.size.height = 460-70-r.size.height; contentView.frame = rect; }]; } -(void)keyboardWillHide:(NSNotification*)note { [UIView animateWithDuration:0.3 animations:^(void) { CGRect rect = contentView.frame; rect.size.height = 174; contentView.frame = rect; }]; }