转自:http://www.cnblogs.com/luyinghuai/archive/2011/08/29/2158328.html
tabBar透明的效果
http://www.cocoachina.com/bbs/read.php?tid=17815
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackTranslucent
animated:YES];
--------------------------
设置Table Cell的背景图的公用类代码
http://www.cocoachina.com/downloads/video/2010/0521/1531.html
#import
<Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UITableViewCell (UITableViewCellExt)
- (void)setBackgroundImage:(UIImage*)image;
- (void)setBackgroundImageByName:(NSString*)imageName;
@end
#import "UITableViewCellExt.h"
@implementation UITableViewCell (UITableViewCellExt)
- (void)setBackgroundImage:(UIImage*)image
{
UIImageView
*imageView = [[UIImageView alloc] initWithImage:image];
imageView.contentMode
= UIViewContentModeCenter;
self.backgroundView
= imageView;
[imageView
release];
}
- (void)setBackgroundImageByName:(NSString*)imageName
{
[self
setBackgroundImage:[UIImage imageNamed:imageName]];
}
@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的官方示例代码
http://www.cocoachina.com/downloads/video/2010/0520/1523.html
----------------------------------------------
把图片切成圆角代码
http://www.cocoachina.com/bbs/read.php?tid-1757.html
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*)image
size:(CGSize)size
{
//
the size of CGContextRef
int
w = size.width;
int
h = size.height;
UIImage
*img = image;
CGColorSpaceRef
colorSpace = CGColorSpaceCreateDeviceRGB();