UIVIew相关知识

title: UIView 相关知识
date: 2015-12-13 22:47
categories: IOS

tags: UIView

小小程序猿
我的博客:http://daycoding.com

masonry 添加约束,并修改约束添加View动画


//添加约束
masView = [UIView new];
masView.backgroundColor = [UIColor redColor];
[self.view addSubview:masView];
[masView mas_makeConstraints:^(MASConstraintMaker *make) {

    make.leading.equalTo(self.view).offset(20);//距离self.view左侧20
    make.top.equalTo(self.view).offset(200);//距离self.view顶部200
    make.width.offset(80);//宽度80
    make.height.offset(80);//高度80
}];

//更新约束并添加动画,如果更新不成功可尝试 mas_remakeConstraints
[masView mas_updateConstraints:^(MASConstraintMaker *make) {
    make.width.and.height.offset(100);
    make.leading.equalTo(self.view).offset(100);
}];

[UIView animateWithDuration:3 animations:^{
    [self.view layoutIfNeeded];
}];

uiview 圆角设置

m_mainImgView.layer.cornerRadius = 6;
m_mainImgView.layer.masksToBounds = YES; 

UIView缩放动画

-(void)mapView:(BMKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    /* 为新添的annotationView添加弹出动画. */
    for (UIView *view in views)
    {
        [self addBounceAnnimationToView:view];
    }

}
/* annotation弹出的动画. */
- (void)addBounceAnnimationToView:(UIView *)view
{
    CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
    
    bounceAnimation.values = @[@(0.05), @(1.1), @(0.9), @(1)];
    bounceAnimation.duration = 0.6;
    
    NSMutableArray *timingFunctions = [[NSMutableArray alloc] initWithCapacity:bounceAnimation.values.count];
    for (NSUInteger i = 0; i < bounceAnimation.values.count; i++)
    {
        [timingFunctions addObject:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    }
    [bounceAnimation setTimingFunctions:timingFunctions.copy];
    
    bounceAnimation.removedOnCompletion = NO;
    
    [view.layer addAnimation:bounceAnimation forKey:@"bounce"];
}
边框阴影
- (void)viewDidLoad  
{  
    [self.view setBackgroundColor:[UIColor whiteColor]];  
    UIView *shadowView=[[UIView alloc] initWithFrame:CGRectMake(100, 100, 120, 120)];  
    [shadowView setBackgroundColor:[UIColor grayColor]];  
    [shadowView.layer setCornerRadius:4.0f];//设置View圆角  
    [shadowView.layer setShadowColor:[UIColor blackColor].CGColor];//设置View的阴影颜色  
    [shadowView.layer setShadowOpacity:0.8f];//设置阴影的透明度  
    [shadowView.layer setOpacity:0.5f];//设置View的透明度  
    [shadowView.layer setShadowOffset:CGSizeMake(4.0, 3.0)];//设置View Shadow的偏移量  
    [self.view addSubview:shadowView];  
    [super viewDidLoad];  
    // Do any additional setup after loading the view, typically from a nib.  
}  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值