iOS移动开发-每日轻松一记第7期

本周主要是记录一些开发中的一些小细节处理

1.去掉导航条UINavigationController底下的黑线条,由于苹果自带的UINav默认是黑色,但是设计师通常对这样的黑线条太粗,太黑不美观为由,要求去掉,或者颜色等。

Nav默认样式:[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

如果要去掉黑线条需要两步:

     1.在Info.plist文件里面增加:key: View controller-based status bar appearance  Value:NO


     2.[navigationBarAppearance setBarStyle:UIBarStyleBlackTranslucent];设置透明


2.UITableView是我们常用的控件,很多时候默认的几种简单样式并不能满足我们的项目需求,这个时候需要自定义Cell,有时候还需要在Cell增加UIButton,这个时候当用户点击的时候我们判断用户是点击那个Cell,从而做相应的处理。判断是点击哪个Cell,有两个办法:

1.使用tag +     2.使用判断坐标,

UICollectionView:

CGPoint point = [_myCollectionView convertPoint:btn_favorites.center fromView:btn_favorites.superview];
NSIndexPath * indexPath = [_myCollectionView indexPathForItemAtPoint:point];

UITableView:

CGPoint point = [_myTableView convertPoint:captchaBtn.center fromView:captchaBtn.superview];
NSIndexPath * indexPath = [_myTableView indexPathForRowAtPoint:point];


3.解决UICollectionView的itemCell不足一屏的时候不能滑动,有时候需要增加一个下拉刷新,如果第一次没有获取到数据,而此时itemCell不足一屏的时候又不能滑动,导致用户无法使用下拉刷新,这个是很郁闷的,为了解决这个问题,我找打一种解决办法,

_myCollectionView.alwaysBounceVertical = YES;(默认NO,如果不足一屏的时候不能垂直滑动)


4.设置头像边距

- (void)doBorderWidth:(CGFloat)width color:(UIColor *)color cornerRadius:(CGFloat)cornerRadius{
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = cornerRadius;
    self.layer.borderWidth = width;
    if (!color) {
        self.layer.borderColor = [UIColor colorWithHexString:@"0xdddddd"].CGColor;
    }else{
        self.layer.borderColor = color.CGColor;
    }
}


5.UITableView 线条缩进:

tableView.separatorInset = UIEdgeInsetsMake(0, cell.lbl_Name.frame.origin.x - 20, 0, 0);


6.隐藏UITableView的滚动条以及修改滚动条的颜色

//隐藏

self.tableView.showsVerticalScrollIndicator = NO;

//修改颜色

self.tableView.indicatorStyle=UIScrollViewIndicatorSty

leWhite;

你可能感兴趣的:(iOS移动开发-每日轻松一记第7期)