饼状图.gif
大家都知道这是通过 CAShapeLayer 和 CABasicAnimation 结合起来实现的,可是其中还是有需要注意的地方,实现的步骤大致如下:
新闻.gif
如果在一个 UIButton 中你设置 setImage并且 setTitle 。你会发现,默认的是 图片在左边,文字在右边。并且这跟 UIButton 的Frame无关。如果想达到下面的效果,就需要改变setImageEdgeInsets、setTitleEdgeInsets设置即可。
Paste_Image.png
//按钮内容完美居中的方法
# 需要注意的是 这里的图片尺寸会采用图片的原始尺寸,所以要注意把
UIButton的尺寸设置的足够大才可以达到效果,否则会有图片文字重合的现象。
# 注意这个方法的调用要在Button的尺寸位置设置过之后才行(Frame,layout 设置后调用才有效果),否则不会生效。
-(void)setButtonContentCenter:(UIButton *) btn
{
CGSize imgViewSize,titleSize,btnSize;
UIEdgeInsets imageViewEdge,titleEdge;
CGFloat heightSpace = 10.0f;
//设置按钮内边距
imgViewSize = btn.imageView.bounds.size;
titleSize = btn.titleLabel.bounds.size;
btnSize = btn.bounds.size;
imageViewEdge = UIEdgeInsetsMake(heightSpace,btn.frame.size.width/2 -imgViewSize.width/2, btnSize.height -imgViewSize.height - heightSpace, btn.frame.size.width/2 -imgViewSize.width/2);
[btn setImageEdgeInsets:imageViewEdge];
titleEdge = UIEdgeInsetsMake(imgViewSize.height +heightSpace, - imgViewSize.width, 0.0, 0.0);
[btn setTitleEdgeInsets:titleEdge];
}
UIButton 可以说是专门为 UILabel和UIImameView添加点击效果的控件,认清楚这个事实,我们运用UIButton的时候就更准确了,我们在实际的开发中这样的会遇到这样的情况,有一个小图标,但是这个图标又能点击,我们只需要把这个Button setImage 然后调整这个图标在Button中的位置即可达到效果
[self.settingButton setImageEdgeInsets:UIEdgeInsetsMake(Scale_Y(5), Scale_X(7), Scale_Y(7), Scale_X(7))];
不过值得一提的是 使用 SDWebImage为UIButtont添加的是 内容Image,而不是 BgImage,这俩个Image可以通过 currentImage 和 currentBackgroundImage 来获取。
使用UIAlertView做登录输入, 默认的是 登录名、密码,我们可以修改 TF的placeholer字体来达到我们想要的效果。
#设置UIAlertView类型
[settingAlert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
#textFieldAtIndex 这个方法可以获取到 UIAlertView 里面的 UITextField,你可以设置它的placeholder也可以获取到里面的值。
UITextField *nameField = [settingAlert textFieldAtIndex:0];
nameField.placeholder = @"试点编号";
创建多个计时器并计时确实是比较消耗系统资源的,不过由于Cell的重用机制,一般也不需要创建太多计时器,时间戳是以秒为单位,十进制的值,时间戳差1意味着俩个时间之前差一秒。我们可以利用Model的Start时间戳来实现cell中的倒计时。
Paste_Image.png
不过这里是另一种实现思路,也挺不错的:iOS在cell中使用倒计时的处理方法
思路不错可以借鉴,大致如下:
加上白色阴影 就可以发光了 如果用的发光字体比较多 可以直接写个font类
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
//[[UIColor colorWithRed:0x3e/255.0 green:0x45/255.0 blue:0x4e/255.0 alpha:1.0] set];
CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 5, [UIColor whiteColor].CGColor); 这样就可以发光了 字体
Paste_Image.png
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, 300, Scale_X(100), 30)];
label.textColor=[UIColor redColor];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:30]];
label.textAlignment = NSTextAlignmentCenter;
[self.sc addSubview:label];
int hour = 23;
int min = 59;
int sec = 59;
label.text = [NSString stringWithFormat:@"%d:%d:%02d", hour, min,sec];
%02d什么意思?
2是宽度很简单。如果整数不够2列就补上0 比如 printf("%02d" ,3); 结果就是 03 如果大于2没有影响 printf("%02d",1234); 1234
Paste_Image.png
[label setFont:[UIFont fontWithName:@"HelveticaNeue-UltraLight" size:50]];
image.png
iOS有私有iPA可以实现这样的效果,不过有可能被拒绝,还是使用UIKit动画比较稳
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(loadingViewAnimationDone)];
[UIView setAnimationDuration:5];
appearView.alpha = 0;
[UIView commitAnimations];
//动画结束时执行的方法
- (void)loadingViewAnimationDone{
}
[label sizeToFit];
会根据label的字 改变 label 的Frame。
image.png
image.png
label.adjustsFontSizeToFitWidth = YES;
期待的效果是,设置一个Label的Frame,让字体自动调整大小,可是这个方法最大设置的字体17.
系统默认最大17,超过这个值就不会自己增大了,而是要自己设置一个更大的值