push到下一页时隐藏tabBar
self.hidesBottomBarWhenPushed=YES;
self.tabBarController.tabBar.hidden = hide;
//self.navigationController.navigationBarHidden=YES;
改变placehoder的字体颜色
UIColor*color=[UIColor blackColor];
textField.attributedPlaceholder=[[NSAttributedString alloc]initWithString:@"请输入" attributes:@{NSForegroundColorAttributeName:color}];
设置button在左边
longlongButton.titleLabel.textAlignment = NSTextAlignmentLeft;
longlongButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
longlongButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
设置导航栏的颜色
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
有多个button 只有一个处于选中状态
-(void)buttonclick:(UIButton*)button
{
if (button!=_button)
{
_button.selected=NO;
_button=button;
}
_button.selected=YES;
}
post请求
NSString*urlString=[[NSString alloc]initWithFormat:@"%@?command=ST_H&access_token=%@",HOST,kGetaccess_token];
NSString*urlString=[[NSString alloc]initWithFormat:@"%@?command=ST_F_FL&access_token=%@",HOST,kGetaccess_token];
label左右都对齐
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 21)];
label.backgroundColor = [UIColor orangeColor];
[self.view addSubview:label];
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:@"TViewController"];
//计算文字大小,参数一定要符合相应的字体和大小
CGSize attributeSize = [attributeString.string sizeWithAttributes:@{NSFontAttributeName:label.font}];
//计算字符间隔
CGSize frame = label.frame.size;
NSNumber *wordSpace = [NSNumber numberWithInt:(frame.width-attributeSize.width)/(attributeString.length-1)];
//添加属性
[attributeString addAttribute:NSKernAttributeName value:wordSpace range:NSMakeRange(0, attributeString.length)];
label.attributedText = attributeString;
label自动换行
rightLab.lineBreakMode = NSLineBreakByWordWrapping;
rightLab.numberOfLines = 0;
cell右边的>属性
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
去掉tableView中多余的行
_tableView.tableFooterView=[[UIView alloc]initWithFrame:CGRectZero];
静态变量设置
static NSString * cellIndentfier = @"cellIndentfier";
变导航条颜色:
self.navigationController.navigationBar.barTintColor=BGVIEW_COLOR1;
改变label的字体
label字体居中
peopelLab.textAlignment=NSTextAlignmentCenter;
输入框字体大小
text.font = [UIFont fontWithName:@"Arial" size:20.0f];
text.clearButtonMode = UITextFieldViewModeAlways;
//是否纠错
text.autocorrectionType = UITextAutocorrectionTypeNo;
//再次编辑就清空
text.clearsOnBeginEditing = YES;
//内容的垂直对齐方式 UITextField继承自UIControl,此类中有一个属性contentVerticalAlignment
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
/设置为YES时文本会自动缩小以适应文本窗口大小.默认是保持原来大小,而让长文本滚动
textFied.adjustsFontSizeToFitWidth = YES;
//设置自动缩小显示的最小字体大小
text.minimumFontSize = 20;
//首字母是否大写
text.autocapitalizationType = UITextAutocapitalizationTypeNone;
//管理左上角的网络活动指示器
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
设置btn上面字体大小
_imageSwith.titleLabel.font = [UIFont systemFontOfSize: 14.0];
设置点击cell动画
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//网址uitableView
//webView隐藏滑栏,和自适应
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_webView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[(UIScrollView*)[_webView.subviews objectAtIndex:0] setShowsHorizontalScrollIndicator:NO];
[(UIScrollView*)[_webView.subviews objectAtIndex:0] setShowsVerticalScrollIndicator:NO];
[_webView loadHTMLString:article._content baseURL:nil];
cell点击消失背景颜色
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//把数组拼接成字符串并加,衔接浮
NSString *string = nil;
NSString *lastString = @"";
for (NSString *value in _selectArray) {
string = [NSString stringWithFormat:@"%@,%@", lastString, value];
NSLog(@"value:%@", value);
NSLog(@"string:%@",string);
lastString = [NSString stringWithFormat:@"%@", string];
}
NSLog(@"拼接输出:%@", string);
//替换字符
str =[str stringByReplacingOccurrencesOfString:@"world" withString:@"India"];
NSString* textStr=[textString substringFromIndex:2];//从第二个字符开始截取
[textString rangeOfString:@"img"].location !=NSNotFound / / //包含
我们会用到这个函数
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//我让第一个cell 点击的时候没有反应
if (indexPath.row ==0) {
returnnil;
}
return indexPath;
}
//改变webView字体大小
1 - (void)webViewDidFinishLoad:(UIWebView *)webView方法中加入js代码
2 NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '60%'";
3 [_webView stringByEvaluatingJavaScriptFromString:str];
1 NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f;document.body.style.color=%@",fontSize,fontColor];
2 [webView stringByEvaluatingJavaScriptFromString:jsString];
//改变webView上图片大小
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function ResizeImages() { "
"var myimg,oldwidth;"
"var maxwidth=%f;" //缩放系数
"for(i=0;i <document.images.length;i++){"
"myimg = document.images[i];"
"if(myimg.width > maxwidth){"
"oldwidth = myimg.width;"
"myimg.width = maxwidth;"
"myimg.height = myimg.height * (maxwidth/oldwidth);"
"}"
"}"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);",webView.frame.size.width-20]];
[webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
__weak ASIFormDataRequest * dataRequest = request; 加上 这句 在下面
数据这里 用 dataRequest