制作圆角button等
//必须导入的空间
#import<QuartzCore/QuartzCore.h>
就拿view来举例
view.layer.masksToBounds=YES; //设置为yes,就可以使用圆角
view.layer.cornerRadius= 5; //设置它的圆角大小
view.layer.borderWidth=1; //视图的边框宽度
view.layer.borderdg= [[UIdggray dg].CGdg]; //视图的边框颜色
制作阴影NavBar稍后附上代码
按钮从A点平滑到B点
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL
- (void)move
{
__block CGRect rect = button.frame;
[UIView animateWithDuration:0.5
animations:^{
//button.transform = CGAffineTransformMakeRotation(3.14);
button.transform = CGAffineTransformMakeTranslation(20, 20);
}
completion:^(BOOL finished){
rect.origin.x+=20;
rect.origin.y+=20;
button.frame = rect;
}];
}
- (IBAction)bkTap:(id)sender
{
[self move];
}
//以上存在第一次有用后在不起作用,改成如下:
fOffsetX,fOffsetY表示移动的话,代码这么写就对了:
fOffsetX+=20;
fOffsetY+=20;
CGAffineTransformMakeTranslation(fOffsetX, fOffsetY);
//从上拉到下
//show
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
//显示tableview时,展开当前view
self.frame = CGRectMake(90, 122, 210,28);
m_tableViewDownList.frame = CGRectMake(0, 28, self.frame.size.width, nHeight);
[UIView commitAnimations];
//hide
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.frame =CGRectMake(90, 122, 210,28);
m_tableViewDownList.frame = CGRectMake(0, 28, self.frame.size.width, 0);
[UIView commitAnimations];
//加入动画淡入淡出
[UIView animateWithDuration:1.0 animations:^{
m_tableViewDownList.alpha = 0.0;
m_tableViewDownList.alpha = 1.0;
}];