PHP 7.4 新语法:箭头函数

2019-5-10 dingshangchao php开发

短闭包,也叫做箭头函数,是一种用 php 编写的短函数。

阅读全文>>

评论(0) 浏览(887)

简单的网络加载图的实现

2019-5-10 王建伟 iOS开发

在编写项目的时候我们需要进行网络的加载,那么网络加载需要时间和重新加载的选项,所以我们可以需要一个加载界面,在网络加载的过程中,重新加载的时候呈现

编辑一个简单的网络加载界面,我们需要一个加载动画,以及加载成功或者失败的处理方法

1.建立一个UIView的子类,LoadingView

2.我们需要的属性:
a:CAShapeLayer*_loadingShapeLayer(制作简单动画);
b:UILabel*promptLabel(提示文字);
c:UIButton*reloadButton(重新加载按键) ;
d:LoadingFailBlock failBlock(加载失败的事件处理块)

3.初始化界面

+(LoadingView*)ShowLoadingViewFrame:(CGRect)frame withSuperView:(UIView *)view{
     LoadingView*loadingview=[[LoadingView alloc]initWithFrame:frame];
     [view addSubview:loadingview];
     [loadingview loadingShapeLayerAnimation];
     return loadingview;
}

-(instancetype)initWithFrame:(CGRect)frame{
    if(self=[super initWithFrame:frame]){
        self.backgroundColor=[UIColor whiteColor];
        _loadingShapeLayer=[[CAShapeLayer alloc]init];
        _loadingShapeLayer.frame=SPFrame(frame.size.width/2-40, frame.size.height/2-100, 80,80 );
        _loadingShapeLayer.path=[UIBezierPath bezierPathWithOvalInRect:SPFrame(0, 0, 80,80 )].CGPath;
        _loadingShapeLayer.fillColor=nil;
        _loadingShapeLayer.strokeColor=[UIColor lightGrayColor].CGColor;
        _loadingShapeLayer.lineWidth=2;
        _loadingShapeLayer.lineJoin=kCALineCapRound;
        _loadingShapeLayer.lineDashPattern=@[@15,@8];
        [self.layer addSublayer:_loadingShapeLayer];
        
        promptLabel=[[UILabel alloc]initWithFrame:SPFrame(frame.size.width/2-40, frame.size.height/2-100, 80,80 )];
        promptLabel.backgroundColor=[UIColor clearColor];
        promptLabel.text=@"正在加载";
        promptLabel.textColor=[UIColor lightGrayColor];
        promptLabel.font=SPFont(15);
        promptLabel.textAlignment=NSTextAlignmentCenter;
        [self addSubview:promptLabel];
      
    }
    
    return self;
}

4.实现方法:加载成功

-(void)LoadingSuccessComplation:(void (^)(void))complation{
    SPSelf;
    [UIView animateWithDuration:2 delay:0 usingSpringWithDamping:1 initialSpringVelocity:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
        weakSelf.transform=CGAffineTransformMakeScale(0.001, 0.001);
    } completion:^(BOOL finished) {
        [weakSelf removeFromSuperview];
        
    }];
    
    if(complation){
       complation();
    }

    
}

5.实现方法:加载失败

- (void)LoadingFailComplation:(void (^)(void))complation{
    [self stopLoadingShapeLayerAnimation];
    promptLabel.text=@"加载失败";
    [self createReloadingButton];
    SPSelf;
    if(complation){
        weakSelf.failBlock = complation;
    }
    
}
-(void)createReloadingButton{
    reloadButton=[[UIButton alloc]initWithFrame:SPFrame(0, 0, 100, 30)];
    reloadButton.center=SPPoint(self.frame.size.width/2, self.frame.size.height/2+50);
    [reloadButton setTitle:@"重新加载" forState:UIControlStateNormal];
    [reloadButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    reloadButton.backgroundColor=[UIColor whiteColor];
    reloadButton.layer.cornerRadius=14;
    reloadButton.layer.masksToBounds=YES;
    reloadButton.layer.borderWidth=1;
    reloadButton.layer.borderColor=[UIColor orangeColor].CGColor;
    reloadButton.titleLabel.font=SPFont(14);
    [reloadButton addTarget:self action:@selector(reloadEvent) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:reloadButton];
    
}
/*
 *重新加载按键点击事件*
 */
-(void)reloadEvent{
    [reloadButton removeFromSuperview];
    [self loadingShapeLayerAnimation];
    self.failBlock();
    
}

6.动画实现

/*
 *load圈转动*
 */
-(void)loadingShapeLayerAnimation{
    CABasicAnimation*rotate=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotate.fromValue=0;
    rotate.toValue=@(M_PI*2);
    rotate.duration=3;
    rotate.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    rotate.repeatCount=HUGE;
    rotate.fillMode=kCAFillModeForwards;
    rotate.removedOnCompletion=NO;
    [_loadingShapeLayer addAnimation:rotate forKey:rotate.keyPath];
    
}

评论(0) 浏览(1075)

动态获取权限

2019-5-8 liuyingcong 安卓开发

   

阅读全文>>

评论(0) 浏览(1114)

docker之Dockerfile

2019-5-7 hubo 服务器

docker之Dockerfile

阅读全文>>

评论(0) 浏览(1787)

JS实现图片轮播效果 支持IE6

2019-4-30 zhulinan Web前端

原生JS实现网页中的图片水平方向或竖直方向的轮播效果 ...

阅读全文>>

评论(0) 浏览(1271)

系统权限设计(五张表)

2019-4-30 dingshangchao php开发

大致用到5张表:三张主表,两张从表

主表:用户表(UserInfo)、角色表(RoleInfo)、菜单表(MenuInfo)
从表:用户角色表(UserRole)、角色菜单表(RoleMenu)。

阅读全文>>

评论(0) 浏览(1905)

对mysql数据库初始化过程中报错 Could not find ./bin/my_print_defaults

2019-4-26 dingshangchao 数据库

对mysql数据库初始化过程中,会有如下报错信息:
1
2
3
4
5
6
7
[root@localhost scripts]# ./mysql_install_db --user=mysql
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

阅读全文>>

评论(0) 浏览(1122)

版式设计小技巧

2019-4-26 zhenggaoyun 视觉设计

版式设计小技巧...

阅读全文>>

评论(0) 浏览(1045)

轮播图的封装

2019-4-26 王建伟 iOS开发

新产品项目中需要编写一个轮播图的功能,效果如下图所示:

其中我们需要用到一个第三方库:iCarousel,这是一个做轮播图非常强大的库,基本可以满足日常开发的需求,我们将在此库的基础上编写实现我们需要的轮播图

首先建立一个基础与UIView的子类:NSRoastView

需要2个属性,1.NSTimer用来实现图片的自动轮播;2.iCarousel第三方库

初始化

实现iCarousel代理方法

实现方法让他能自动轮播

评论(0) 浏览(1358)

从零开始画图标系列

2019-4-19 zhenggaoyun 视觉设计

工具图标的三种设计类型...

阅读全文>>

评论(0) 浏览(989)

网站备案号:京ICP备11043289号-1 北京市公安局网络备案 海1101084571
版权所有 北京育灵童科技发展有限公司 Copyright © 2002-2024 www.elight.cn, All Rights Reserved