无题
dispatch_after:延时操作
//下面可以让前面数组中对象,都执行后面的方法
[self.selectBtns makeObjectsPerformSelector:@selector(setSelected:) withObject:@(NO)];
/* Return true if point' is contained in
rect', false otherwise. */
bool CGRectContainsPoint(CGRect rect, CGPoint point)
//UITextField设置搜索图标
UITextField *searBar = [[UITextField alloc]init]; //背景 searBar.background = [UIImage resizeImageWithName:@"searchbar_textfield_background"]; //尺寸 searBar.frame = CGRectMake(0, 0, 300, 30); //左边,搜索图标 UIImageView *iconView = [[UIImageView alloc]initWithImage:[UIImage imageWithName:@"searchbar_textfield_search_icon"]]; iconView.contentMode = UIViewContentModeCenter; iconView.frame = CGRectMake(0, 0, 30, 30); searBar.leftView =iconView ; searBar.leftViewMode = UITextFieldViewModeAlways;//左边的view永远显示 //字体 searBar.font = [UIFont systemFontOfSize:13]; //文本框右边的删除按钮 searBar.clearButtonMode = UITextFieldViewModeAlways; // searBar.placeholder = @"搜索..."; //设置提醒文字 NSMutableDictionary *arrts = [NSMutableDictionary dictionary];//文本框中隐藏的搜索按钮 arrts[NSForegroundColorAttributeName] = [UIColor grayColor]; searBar.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"搜索..." attributes:arrts];
self.navigationItem.titleView = searBar;
// 设置键盘右下角按钮的样式
self.returnKeyType = UIReturnKeySearch;
self.enablesReturnKeyAutomatically = YES;
//高亮的时候,不要调整图标
titleButton.adjustsImageWhenHighlighted = NO;
四舍五入
int pageInt = (int)(page + 0.5);;
按钮属性
checkBox.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);//内边距,按钮内部四周的间距 checkBox.titleEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
checkBox.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
//请求url的绝对路径
NSString *urlStr = request.URL.absoluteString;
urlStr rangeOfString:@"code=")//包含
//如果服务器返回的数字很大,就用long long ,比如说主键
KVC:会吧字典所有的key-value赋值给对应的属性。
//taleivew的黑色分割线,cell分割线去掉 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//去掉cell的背景色 self.backgroundColor = [UIColor clearColor];
05-19:
<04-发微博04-自定义toolbar.mp4>:15:00修改项目名称
//定时检查未读数 // [self checkUnReadCount];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(checkUnReadCount) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
/** * 当一个对象从xib或者storyboard中加载完毕后,就会调用一次 ///- (void)awakeFromNib//{// NSLog(@"awakeFromNib");//// self.titleFont = [UIFont systemFontOfSize:14];//}/* * 从文件中解析一个对象的时候就会调用这个方法 /- (id)initWithCoder:(NSCoder )decoder{ if (self = [super initWithCoder:decoder]) { [self setup]; } return self;}/ * 通过代码创建控件的时候就会调用 /- (id)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self setup]; } return self;}/* * 初始化 */- (void)setup{ self.titleFont = [UIFont systemFontOfSize:14]; self.titleLabel.font = self.titleFont; // 图标居中 self.imageView.contentMode = UIViewContentModeCenter;
}
设置子控件的frame用: -(void)layoutSubviews
有时候按钮长按变灰,而不是我们设置的高亮图片,是由于type设置为system不实,custom
/** * 系统第一次使用这个类的时调用,1个类只调用一次。 */
+(void)initialize