NSString*contentStr = [NSStringstringWithFormat:@" %@",DetailStr];1.移除所有子視圖的系統(tǒng)方法
[webViewloadHTMLString:contentStrbaseURL:nil];NSString*contentStr = [NSStringstringWithFormat:@"
%@
",DetailStr];
[webViewloadHTMLString:contentStrbaseURL:nil];NSString*contentStr = [NSStringstringWithFormat:@"
%@
",DetailStr];
[webViewloadHTMLString:contentStrbaseURL:nil];NSString*contentStr = [NSStringstringWithFormat:@"
%@
",DetailStr];
[webViewloadHTMLString:contentStrbaseURL:nil];
[cell.contentView.subviewsmakeObjectsPerformSelector:@selector(removeFromSuperview)];
4.按鈕單選的一種實現(xiàn)方法?
timeBtn 為全局變量
if(timeBtn==nil)
{
sender.selected=YES;
timeBtn= sender;
}
elseif(timeBtn!=nil&&timeBtn== sender)
{
timeBtn.selected=YES;
}
elseif(timeBtn!= sender &&timeBtn!=nil)
{
timeBtn.selected=NO;
sender.selected=YES;
timeBtn= sender;
}
}
5.label自適應(yīng)高度
NSDictionary * attributeDic = [NSDictionary dictionaryWithObjectsAndKeys:font_13, NSFontAttributeName, nil];
CGSize size = CGSizeMake(k_Width - 40, 100); // 設(shè)置最大寬高
CGSize addressSize = [_context boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributeDic context:nil].size;
addressLabel.numberOfLines = 0;
6.導(dǎo)航欄背景顏色
1、info.plist里添加:View controller-based status bar appearance
設(shè)置為NO盲再。
2筐付、代碼里添加:[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
3塘慕、導(dǎo)航欄文字顏色
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
或者
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
?7.textField的placeholderu顏色
1、NSDictionary *TFdic = @{NSForegroundColorAttributeName:[UIColor grayColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:16]};
2、_UserNameTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"請輸入手機號/郵箱" attributes:TFdic];贬养。
?8、圖片拉伸?
UIImage stretchableButtonImage = [buttonImagestretchableImageWithLeftCapWidth:12topCapHeight:0];
參數(shù)一:距離圖片左邊的像素距離
參數(shù)二:距離圖片上邊的像素距離
9琴庵、設(shè)置label行間距?
UILabel設(shè)置行間距等屬性:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:contentLabel.text];;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
[paragraphStyle setLineSpacing:5];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, contentLabel.text.length)];
contentLabel.attributedText = attributedString;
10误算、NSDate 和 NSString互轉(zhuǎn)
1、字符串轉(zhuǎn)時間
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//實例化一個NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//設(shè)定時間格式,要注意跟下面的dateString匹配细卧,否則日起將無效
NSDate *date =[dateFormat dateFromString:@"2013-3-11 10:00:01"];
2尉桩、時間轉(zhuǎn)字符串
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//實例化一個NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//設(shè)定時間格式
NSString *dateString = [dateFormat stringFromDate:[NSDate date]]; //求出當(dāng)天的時間字符串,當(dāng)更改時間格式時贪庙,時間字符串也能隨之改變
=========
NSUInteger unitFlags = NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSCalendar * calendar = [[NSCalendar alloc] initWithCalendarIdentifier:@"1"];
NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:myCalendar.currentDate];
[calendarHeaderView addSubview:currentMonthLabel];
11蜘犁、webView亂碼?
12、修改webView字體大小止邮、字體顏色这橙、背景顏色
// 修改網(wǎng)頁字體大小
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
//字體大小
[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '330%'"];
//字體顏色
[webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'gray'"];
//頁面背景色
[webView stringByEvaluatingJavaScriptFromString:@“document.getElementsByTagName('body')[0].style.background='#2E2E2E'"];
}
————— 參考:http://blog.csdn.net/chenyong05314/article/details/40599139
13、將cell里的圖片放大到全屏
bigImgButton.frame= [UIScreenmainScreen].bounds;
AppDelegate*delegate = (AppDelegate*)[UIApplicationsharedApplication].delegate;
[delegate.windowaddSubview:bigImgButton];
14导披、縮放圖片
//放大縮小圖片
- (void)pinchGestureAction:(UIPinchGestureRecognizer*)pinchGesture
{
if(pinchGesture.state==UIGestureRecognizerStateEnded) {
currentScale= pinchGesture.scale;
}elseif(pinchGesture.state==UIGestureRecognizerStateBegan&¤tScale!=0) {
pinchGesture.scale=currentScale;
}
//設(shè)置圖片尺寸縮放界限
CGFloatminScale =0.5;
CGFloatmaxScale =2.5;
if(pinchGesture.scale<= minScale) {
pinchGesture.scale= minScale;
}
if(pinchGesture.scale>= maxScale) {
pinchGesture.scale= maxScale;
}
if(pinchGesture.scale!=NAN) {
pinchGesture.view.transform=CGAffineTransformMakeScale(pinchGesture.scale, pinchGesture.scale);
}
}
14屈扎、跳到子視圖 點亮tableBar
15、更改導(dǎo)航欄顏色?
[self.navigationController.navigationBarsetBarTintColor:[UIColorcolorWithRed:27/255.0green:74/255.0blue:70/255.0alpha:1.000]];