IOS开发基础知识--碎片31

1:UITableViewCell drawInRect 在iOS7中失败

解决办法,把Cell里的布局移到新建的View里面,在View里面实现DrawInRect,然后在Cell里面加载View,代码如下:

@implementation CustomTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:[[CustomContentView alloc]initWithFrame:self.contentView.bounds]];
    }
    return self;
}

@end
@implementation CustomContentView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


- (void)drawRect:(CGRect)rect
{
    NSDictionary * attributes = @{
                                  NSFontAttributeName : [UIFont fontWithName:@"Helvetica-bold" size:12],
                                  NSForegroundColorAttributeName : [UIColor blackColor]
                                  };

    [@"I <3 iOS 7" drawInRect:rect withAttributes:attributes];
}

@end

 

2:YTKNetwork的内容

YTKNetwork 是猿题库 iOS 研发团队基于 AFNetworking 封装的 iOS 网络库,其实现了一套 High Level 的 API,提供了更高层次的网络访问抽象。

YTKNetwork 使用基础教程
https://github.com/yuantiku/YTKNetwork/blob/master/BasicGuide.md

YTKNetwork 使用高级教程
https://github.com/yuantiku/YTKNetwork/blob/master/ProGuide.md

 

3:打开跟关闭MAC隐藏的文件

但通过在"终端"中输入命令, 就可以在Finder中显示出来:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

其实就是修改系统的一个设置, 再重启Finder

同样的道理可以让Finder不显示隐藏文件:

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder

 

4:github readme.md 添加图片 

简要:

将图片放在仓库里面,在文件里链接它,最后 push 到 github 上。

github 图片链接格式:

(http://github.com/yourname/your-repository/raw/master/images-folder/xxx.png)

然后在 README.md 里添加:

例如:我在我的 dotvim 文件夹下一个 screenshots 目录,在该目录里有一个 vim-screenshot.jpg 截图。那么添加链接的方式如下

![image](https://github.com/ButBueatiful/dotvim/raw/master/screenshots/vim-screenshot.jpg)

注意:当第一次写完ReadMe文件后,它会保存到项目中,如果要对它进行修改,可以在本地修改后,然后在PUSH到远端项目中;

 

5:关于导航栏透明度的设置及顶部布局起点位置设置

属性:translucent

关闭

self.navigationController.navigationBar.translucent = NO;

开启

self.navigationController.navigationBar.translucent = YES;

 

属性:automaticallyAdjustsScrollViewInsets

当 automaticallyAdjustsScrollViewInsets 为 NO 时,tableview 是从屏幕的最上边开始,也就是被 导航栏 & 状态栏覆盖

当 automaticallyAdjustsScrollViewInsets 为 YES 时,也是默认行为

 

6:ios 7 statusbar 状态栏 navigationbar的颜色而改变

ios7以下的版本设置导航栏背景颜色可以使用

[[UINavigationBar appearance] setTintColor:[UIColor orangeColor]];

ios7以后:

[[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]];

默认带有一定透明效果,可以使用以下方法去除系统效果

[navigationController.navigationBar setTranslucent:NO];

 

项目需要将状态栏的文字颜色设置为白色,以下方法即可

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

改变后需要及时刷新的调用

[viewController setNeedsStatusBarAppearanceUpdate];

如果没有效果,需要在plist文件里设置

View controller-based status bar appearance  = NO

info.plist中 View controller-based status bar appearance这个属性 View controller-based status bar appearance =NO 这个设置为:View Controller 不对status Bar 显示进行操作

posted @ 2016-01-04 23:42  踏浪帅  阅读(365)  评论(0编辑  收藏  举报