-(void)changeSize:(UIView*)tmp beginSize:(float)begins endSize:(float)ends time:(float)time{
tmp.scale = begins;
[UIView beginAnimations:nil context:tmp];
[UIView setAnimationDuration:time];
tmp.scale = ends;
[UIView commitAnimations];
}
//单位时间内改变View的透明度
-(void)appear:(UIView*)tmp beginAlphaSize:(float)begins alphaEndSize:(float)ends time:(float)time{
tmp.alpha = begins;
[UIView beginAnimations:nil context:tmp];
[UIView setAnimationDuration:time];
tmp.alpha = ends;
[UIView commitAnimations];
}
//获取当前系统的时间
NSString* date;
NSDateFormatter* formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"YYYY-MM-dd-hh:mm:ss:ms"];
date = [formatter stringFromDate:[NSDate date]];
NSLog(@"%@",date);
//修改 左侧 返回键的背景颜色
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
//图片随机移动
-(void)MoveRand:(UIView*)tmpView{
// +[Utility getRandomNumber:-10 to:10]
tmpView.point = CGPointMake(tmpView.point.x + [Utility getRandomNumber:-1 to:2], tmpView.point.y);
[self performSelector:@selector(MoveRand:) withObject:tmpView afterDelay:0.5];
}
//数组随机排序
NSArray *array = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", nil];
array = [array sortedArrayUsingComparator:(NSComparator)^(id obj1, id obj2) {
return (arc4random() % 3) - 1;
}];
NSLog(@"array:%@", array);
//取出系统字体
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
printf( "Family: %s \n", [familyName UTF8String] );
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames ){
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}
//宏定义颜色值
#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((rgbValue >> 16) & 0xFF)/255.f \
green:((rgbValue >> 8) & 0xFF)/255.f \
blue:(rgbValue & 0xFF)/255.f \
alpha:1.0f]
view有一个属性layer,通过设置cornerRadius来设置圆角的半径,view是正方形的才能保证通过调整圆角半径来形成圆形头像
[view.layer setCornerRadius:CGRectGetHeight([view bounds]) / 2];
view.layer.masksToBounds = YES;
然后再给图层添加一个有色的边框,类似qq空间头像那样
view.layer.borderWidth = 5;
view.layer.borderColor = [[UIColor whiteColor] CGColor];
view.layer.contents = (id)[[UIImage imageNamed:@"backgroundImage.png"] CGImage];
这样就可以制作成圆形头像了,很实用的。
//去掉tableview滚动条
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.showsVerticalScrollIndicator = NO;
//直接让self.view 旋转90°
#define degreesToRadinas(x) (M_PI * (x)/180.0)
self.view.transform=CGAffineTransformMakeRotation(degreesToRadinas(90));
//遍历字典
NSEnumerator *keys=[applist keyEnumerator];
id keyIndic=nil;
NSString *indexKey;
while ((keyIndic=[keys nextObject])!=nil) {
// id valueForkey=[applist objectForKey:keyIndic];
NSLog(@"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++key=%@",keyIndic);
indexKey=keyIndic;
}
//枚举数组
[arry enumerateObjectsUsingBlock:^(NSDictionary *dic, NSUInteger idx, BOOL *stop)
{
NSLog(@"object(%lu)'s description is %@",(unsigned long)idx, [dic description]);
}
];
//可变数组申请内存
BtnTagArray = [[NSMutableArray alloc] initWithCapacity:1];
本文详细介绍了如何使用Objective-C语言在单位时间内实现图片与View的动画效果,包括放大、透明度变化及随机移动。同时,文章还展示了如何修改返回键背景颜色、制作圆形头像及调整UI元素布局。此外,通过宏定义颜色和遍历字典的实例,进一步丰富了UI交互体验。最后,介绍了如何去除表格视图滚动条和直接旋转视图的方法,为开发者提供了全面的UI操作指南。
3187

被折叠的 条评论
为什么被折叠?



