解决同时按两个按钮进两个view的问题。[button setExclusiveTouch:YES];
在6p模拟器上输出宽度是414,在6p真机上输出是375
是测试机本身设置的问题,到设置-显示与亮度里面把显示模式改成“标准”
图片拉伸
UIImage* img=[UIImage imageNamed:@"2.png"];//原图
UIEdgeInsets edge=UIEdgeInsetsMake(0, 10, 0,10);
//UIImageResizingModeStretch:拉伸模式,通过拉伸UIEdgeInsets指定的矩形区域来填充图片
//UIImageResizingModeTile:平铺模式,通过重复显示UIEdgeInsets指定的矩形区域来填充图
img= [img resizableImageWithCapInsets:edge resizingMode:UIImageResizingModeStretch];
self.imageView.image=img;
UITableView顶部有空白区,cell不在最顶端问题
iOS 7 viewcontroller新增属性automaticallyAdjustsScrollViewInsets,即是否根据按所在界面的
navigationbar与tabbar的高度,自动调整scrollview的 inset,设置为no,让它不要自动调整就可以了
self.automaticallyAdjustsScrollViewInsets=NO;
修改tableViewCell选中状态的颜色
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor whiteColor];
默认选中第一个cell
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[_leftSiftTable selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
设置btn上的字左对齐
timeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
timeBtn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);
修改textFieldplaceholder字体颜色和大小
textField.placeholder = @"username is in here!";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
改变UILable字体大小,使内容自适应
方法一:lab.adjustsFontSizeToFitWidth=YES;
方法二:
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
修改状态栏字体颜色
只能设置两种颜色,黑色和白色,系统默认黑色
设置为白色方法:
(1)在plist里面添加Status bar style,值为UIStatusBarStyleLightContent(白色)或UIStatusBarStyleDefault(黑 色)
(2)在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO
关于右划返回上一级
自定义leftBarButtonItem后无法启用系统自带的右划返回可以再设置以下代码
self.navigationController.interactivePopGestureRecognizer.delegate = self;
去掉导航栏下边的黑线
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
点击cell单元格的时候取消选中单元格
-(void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
修改pagecontrol颜色
_pageControl.currentPageIndicatorTintColor=SFQRedColor;
_pageControl.pageIndicatorTintColor=SFQGrayColor;
UIView和UIImageview的userInteractionEnabled属性UIView的userInteractionEnabled默认是YES
UIImageview的userInteractionEnabled默认是NO
userInteractionEnabled=YES则代表该视图可交互,则不响应父视图。
userInteractionEnabled=NO不可交互,则该视图上的子视图也不会响应。
去掉UITableView的section的粘性,使其不会悬停。
//有时候使用UITableView所实现的列表,会使用到section,但是又不希望它粘在最顶上而是跟随滚动而消失或者出现
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == _tableView) {
CGFloat sectionHeaderHeight = 36;
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);
}
}
}