iOS小工具

obj-c double类型显示去掉多余的0

   double someNumber = 2.000;
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
    NSLog(@"%@",[formatter stringFromNumber:[NSNumber numberWithDouble:someNumber]]);

打印结果:2

转自: Remove trailing zeros of a double only when necessary

unicode转为中文字符

NSString *input = @"\\u6211\\u7231\\u4f60,我♥︎";
NSString *convertedString = [input stringByApplyingTransform:@"Any-Hex/Java"
                                                     reverse:YES];

NSLog(@"convertedString: %@", convertedString);

打印结果:convertedString: 我爱你,我♥︎你

转自:Using Objective C/Cocoa to unescape unicode characters, ie \u1234

iOS隐藏控件,类似于android的view.gone

转自:https://github.com/neevek/UIView-Visibility

设置tableView的header不悬浮

当tableview style设置为ground时,每个section的header会跟随tableview一起上下滑动;当style设置为plain时,每个section的header会悬浮在屏幕最上面,直到下一个section的header划过来,把当前的替换掉。现在的问题是,可以在style为plain时,让header也跟随tableview一起上下滚动吗,而不停在屏幕最上的部分。

//去掉UItableview headerview黏性
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.myTableView)
    {
        CGFloat sectionHeaderHeight = YOUR_HEIGHT;
        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
        } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
        }
    }
}

转自:http://blog.sina.com.cn/s/blog_aedec7030101l1q6.html

 

posted on 2016-01-16 00:51  a0000  阅读(450)  评论(0编辑  收藏  举报

导航