0815-超级猜图(上半部分用story board 搭建界面)(重写对象description 方便Log打印该对象 )(解决description乱码问题 - 数组自定义分类)(数组的详细遍历 enumerateObjectsUsingBlock)(数组排序 和随机函数 数组乱序)(iphone开发appIcon需要准备的图片)(iphone启动图标 launchImage)( 不能够交互的)
------------------------
上半部分用story board 搭建界面
步骤:
1、button图片和背景图片 button设置inset属性 将图片挤压小
2、状态栏有电池 重写方法 preferredStatusBarStyle
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
}
3、Button做蒙版
4、取消自动布局(因为在自动布局的情况下 设置frame失效)
5、子视图提到最前面 self.view bringSubviewToFront
6、从父视图删去 button removeFromSuperView
7、取消button的 highlighted adusts image 点击按着不放的时候图片不会变暗了
8、取消 金币的user interaction enabled
------
拼接字符串 字符串是否相等 截取字符串
NSMutableString strM = [NSMutableString String];
[strM.appendString:@"aaa"];
[strM isEqualToString:@"aaa"]
[str subStringToIndex:1];//截取头一个字符
---------------
重写对象description 方便Log打印该对象
步骤:
重写description (NSLog(@"%@",对象)
- (NSString *)description
{
return [NSString stringwithFormat:@"<%@: %p> {answer: %@, icon: %@}",self.class, self, self.answer, self.icon];
}
对象默认description格式
[NSString stringwithFormat:@"<%@: %p">,self.class,self];
--------------
解决description乱码问题 - 数组自定义分类
拖进来一个数组的自定义分类,不需要import就可以用了
代码:
NSArray+Log.h
#import <Foundation/Foundation.h>
@interface NSArray (Log)
@end
NSArray+Log.m
#import "NSArray+Log.h" @implementation NSArray (Log) - (NSString *)descriptionWithLocale:(id)locale { NSMutableString *strM = [NSMutableString stringWithString:@"(\n"]; for (id obj in self) { [strM appendFormat:@"\t%@,\n", obj]; } [strM appendString:@")\n"]; return strM; } @end
----------------------
数组的详细遍历 enumerateObjectsUsingBlock
// 参数:对象,索引,是否中断 // 数组的块方法遍历的效率比for in高 [array enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) { NSLog(@"%@", obj); // idx == 1 退出循环 if (idx == 1) { *stop = YES; } }];
-------------------
数组排序 和随机函数 数组乱序
// 排序 array = [array sortedArrayUsingComparator:^NSComparisonResult(NSNumber *num1, NSNumber *num2) { /** 1 4 5 2 4 1 5 2 4 1 5 2 5 4 1 2 5 4 1 2 5 4 2 1 */ NSLog(@"%@ %@", num1, num2); // 升序 // return [num1 compare:num2]; // 降序 return [num2 compare:num1]; }];
// 随机 arc4random_uniform(10) => 0~9之间的随机数
// 乱序 array = [array sortedArrayUsingComparator:^NSComparisonResult(NSNumber *num1, NSNumber *num2) { // 乱序=>一会升序,一会降序 // 随机 // arc4random_uniform(10) => 0~9之间的随机数 int seed = arc4random_uniform(2); if (seed) { return [num1 compare:num2]; } else { return [num2 compare:num1]; } }];
------
iphone开发appIcon需要准备的图片
help ->Xcode overview 搜索文章 Icons for iPhone-only Apps
做iphone开发需要准备这些图片就可以了
启动图标AppIcon 说明
手机采用点dp作为基本单位 非视网膜屏宽度是320个点
视网膜屏里宽度上占据320个dp点 640px 视网膜屏是320个点
1、
spotlight是搜索出现应用程序的图片
2、
2x 40pt 对应的是80*80像素
-------
iphone启动图标 launchImage
R4对应的是retina 4寸屏 iphone5s等 高度为568dp 高度占用1136px
------
不能够交互的几种情况
/**
不能够交互的
alpha <= 0.01
hidden = YES
userInteraction = NO
父视图不允许交互,也不能交互
在父视图可见范围内,可以交互,范围之外不能交互
*/
---------
UIImageView默认是不允许点击的
-----------------------
其他没用的
str.length == 0 比str == nil 判断 效率更高
ios7人及设计指南(有时间可以看看)
http://isux.tencent.com/ios-human-interface-guidelines-ui-design-basics-ios7.html
for循环内需要有2个以上元素 字符串2个以上字符才能循环

浙公网安备 33010602011771号