阴影
UIView *feeView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 200)];//计费显示
[feeView.layer setBorderWidth: 2.0];
[feeView.layer setCornerRadius:20.0f];
[feeView.layer setMasksToBounds:NO];
[feeView.layer setBorderColor: [[UIColor lightGrayColor] CGColor]];
UIColor * highColor = [UIColor colorWithWhite:1.000 alpha:1.000];
UIColor * lowColor = [UIColor colorWithRed:0.851 green:0.859 blue:0.867 alpha:1.000];
CAGradientLayer * gradient = [CAGradientLayer layer];
[gradient setFrame:[feeView bounds]];
[gradient setColors:[NSArray arrayWithObjects:(id)[highColor CGColor], (id)[lowColor CGColor], nil]];
//the rounded rect, with a corner radius of 6 points.
//this *does* maskToBounds so that any sublayers are masked
//this allows the gradient to appear to have rounded corners
// CALayer * roundRect = [CALayer layer];
// [roundRect setFrame:[feeView bounds]];
// [roundRect setCornerRadius:6.0f];
// [roundRect setMasksToBounds:YES];
// [roundRect addSublayer:gradient];
//
// [feeView.layer insertSublayer:roundRect atIndex:0];
//set the shadow on the view's layer
[feeView.layer setShadowColor:[[UIColor blackColor] CGColor]];
[feeView.layer setShadowOffset:CGSizeMake(0, 0)];
[feeView.layer setShadowOpacity:1.0];
[feeView.layer setShadowRadius:10.0];
[feeView setBackgroundColor:[UIColor whiteColor]];
为视图加边框
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];
UIImageView *contentView = [[MyUIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[contentView setImage:[UIImage imageNamed:@"1.jpg"]];
[contentView setUserInteractionEnabled:YES];
self.view=[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[self.view addSubview:contentView];
self.view.backgroundColor=[UIColor blackColor];
/*
CALayer *layer=[contentView layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:10.0];
[layer setBorderWidth:4.0];
*/
//为视图增加边框
contentView.layer.masksToBounds=YES;
contentView.layer.cornerRadius=20.0;
contentView.layer.borderWidth=10.0;
contentView.layer.borderColor=[[UIColor blueColor] CGColor];
UIImage 图片缩放到指定大小尺寸
2011/03/26 17:43
lazytable 例子
// Set appIcon and clear temporary data/image
UIImage *image = [[UIImage alloc] initWithData:self.activeDownload];
if (image.size.width != kAppIconHeight &;&; image.size.height != kAppIconHeight)
{
CGSize itemSize = CGSizeMake(kAppIconHeight, kAppIconHeight);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[image drawInRect:imageRect];
self.appRecord.appIcon = UIGraphicsGetIma
geFromCurrentImageContext();
UIGraphicsEndImageContext();
}
else
{
self.appRecord.appIcon = image;
}
self.activeDownload = nil;
[image release];
图片缩放到指定大小尺寸
- (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{
// 创建一个bitmap的context
// 并把它设置成为当前正在使用的context
UIGraphicsBeginImageContext(size);
// 绘制改变大小的图片
[img drawInRect:CGRectMake(0, 0, size.width, size.height)];
// 从当前context中创建一个改变大小后的图片
UIImage* scaledImage = UIGraphicsGetImageFromC