tabBar透明的效果
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES]; -------------------------- 设置Table Cell的背景图的公用类代码 #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface UITableViewCell (UITableViewCellExt) - (void)setBackgroundImage:(UIImage*)p_w_picpath; - (void)setBackgroundImageByName:(NSString*)p_w_picpathName; @end #import "UITableViewCellExt.h" @implementation UITableViewCell (UITableViewCellExt) - (void)setBackgroundImage:(UIImage*)p_w_picpath { UIImageView *p_w_picpathView = [[UIImageView alloc] initWithImage:p_w_picpath]; p_w_picpathView.contentMode = UIViewContentModeCenter; self.backgroundView = p_w_picpathView; [p_w_picpathView release]; } - (void)setBackgroundImageByName:(NSString*)p_w_picpathName { [self setBackgroundImage:[UIImage p_w_picpathNamed:p_w_picpathName]]; } @end 调 用示例: // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell setBackgroundImageByName:@"text-background.png"]; } return cell; } -------------------------------------iPhone SDK 解析 xml的官方示例代码 ---------------------------------------------- 把图片切成圆角代码 static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight) { float fw, fh; if (ovalWidth == 0 || ovalHeight == 0) { CGContextAddRect(context, rect); return; } CGContextSaveGState(context); CGContextTranslateCTM(context, CGRectGetMinX(rect), CGRectGetMinY(rect)); CGContextScaleCTM(context, ovalWidth, ovalHeight); fw = CGRectGetWidth(rect) / ovalWidth; fh = CGRectGetHeight(rect) / ovalHeight; CGContextMoveToPoint(context, fw, fh/2); // Start at lower right corner CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); // Top right corner CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); // Top left corner CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); // Lower left corner CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // Back to lower right CGContextClosePath(context); CGContextRestoreGState(context); } + (id) createRoundedRectImage:(UIImage*)p_w_picpath size:(CGSize)size { // the size of CGContextRef int w = size.width; int h = size.height; UIImage *img = p_w_picpath; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst); CGRect rect = CGRectMake(0, 0, w, h); CGContextBeginPath(context); addRoundedRectToPath(context, rect, 10, 10); CGContextClosePath(context); CGContextClip(context); CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage); CGImageRef p_w_picpathMasked = CGBitmapContextCreateImage(context); CGContextRelease(context); CGColorSpaceRelease(colorSpace); return [UIImage p_w_picpathWithCGImage:p_w_picpathMasked]; } 直接调用 createRoundedRectImage.... 返回圆角图片 圆角大小自行修改 CGContextAddArcToPoint.... ------------------------------- 检测iPhone/iPod Touch/iPad设备类型 ------------------------------------- iPhone上气泡式聊天的代码 聊天程序--(UDP通信,bubble代码) 第一个iphone小程序(实现聊天功能) ---------------------------------------- ExpanderController可伸缩框架的代码 ------------------------------------------- 一段模拟水波纹的代码,希望对大家有用 ------------------------------- 根据经纬度计算两点之间距离的Obcective-C代码 其中其中er 就是地球椭球半径,对于google map使用 6378137 就可以了。函数的调用非常简单,几乎使用任何平台:) #define PI 3.1415926 double LantitudeLongitudeDist(double lon1,double lat1, double lon2,double lat2) { double er = 6378137; // 6378700.0f; //ave. radius = 6371.315 (someone said more accurate is 6366.707) //equatorial radius = 6378.388 //nautical mile = 1.15078 double radlat1 = PI*lat1/180.0f; double radlat2 = PI*lat2/180.0f; //now long. double radlong1 = PI*lon1/180.0f; double radlong2 = PI*lon2/180.0f; if( radlat1 < 0 ) radlat1 = PI/2 + fabs(radlat1);// south if( radlat1 > 0 ) radlat1 = PI/2 - fabs(radlat1);// north if( radlong1 < 0 ) radlong1 = PI*2 - fabs(radlong1);//west if( radlat2 < 0 ) radlat2 = PI/2 + fabs(radlat2);// south if( radlat2 > 0 ) radlat2 = PI/2 - fabs(radlat2);// north if( radlong2 < 0 ) radlong2 = PI*2 - fabs(radlong2);// west //spherical coordinates x=r*cos(ag)sin(at), y=r*sin(ag)*sin(at), z=r*cos(at) //zero ag is up so reverse lat double x1 = er * cos(radlong1) * sin(radlat1); double y1 = er * sin(radlong1) * sin(radlat1); double z1 = er * cos(radlat1); double x2 = er * cos(radlong2) * sin(radlat2); double y2 = er * sin(radlong2) * sin(radlat2); double z2 = er * cos(radlat2); double d = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)); //side, side, side, law of cosines and arccos double theta = acos((er*er+er*er-d*d)/(2*er*er)); double dist = theta*er; return dist; } ---------------------------- 巴黎自行车信息查询软件源码 -------------------------------- 自制 iPhone DataGrid 数据列表组件,支持行列锁定 -------------------------------- iPhone播放本地视频的代码 ---------------------------- UIWebView里面长按一个链接后自定义弹出菜单 ------------------------------------------- iPhone上画面切换特效及代码 ------------------------- 永远的扫雷英雄(开源) 登场 -------------------------------- 在iPhone中实现图片缩放 ----------------- 创建iPhone锁定划动条的方法 ------------- UICoverFlowLayer例子:制作iPhone的Cover Flow效果 ----------------------------- 如何在iPhone程序读取数据时显示进度窗 ----------------- UITabBarController 保存调整后的more选项(增加所有TabBar之间切换). -------------------------------------------- NSStirng、NSArray、以及枚举(Method小集合) ------------ UIview动画 ---------------- 搜索功能 ------------- UILabel显示换行的方法 UILabel*label; //设置换行 label.lineBreakMode = UILineBreakModeWordWrap; label.numberOfLines = 0; 换行符还是\n 比如NSString * xstring=@"lineone\nlinetwo" 记得要把label的高度设置的足够显示多行内容。 ------------------ 手把手教你做iphone的soap应用(webservice) --------------------------- 点击Table一行弹出下拉一排按钮的TableViewCell类 ----------------- 一些iPhone开源项目代码 ---------------------- <iOS4>后台运行(Multitasking)以及本地通知(Local Notifications) 有图,有书,有代码,统一打包 ------------------- 开源一个基于MultiTouch事件图片移动和缩放的demo -------------------------