2015/10/2 iOS笔记 细节
2015-10-03 01:47
260 查看
网页如何跳转到想要的位置
<!DOCTYPE html>
<html>
<head>
<title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="rule.css">
<script>
function btnClick()
{
window.location.href = "#howtorecharge";
}
</script>
</head>
<body>
<input type="button" value = "按钮baby" onClick = "btnClick()">
<div>
一、按钮不能交互的几种情况
1,alpha <= 0.01 (0.02就能点了)
2,hidden = YES
3, userInteraction = NO
4, 所在的父视图不允许交互,按钮也不能交互
5,在父视图可见范围内可以交互,超出范围的部分不能交互。
二、UIImageView 默认 不允许用户交互的。
三、乱序
- (void)randomOptions
{
// 对option数组乱序
[self.options sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) {
int seed = arc4random_uniform(2);
if (seed) {
return [str1 compare:str2];
} else {
return [str2 compare:str1];
}
}];
}
四、模型内进行乱序,只在加载的时候做一次乱序。
- (instancetype)initWithDict:(NSDictionary *)dict
{
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dict];
// 对备选按钮进行乱序,只在加载的时候做一次乱序
[self randomOptions];
}
return self;
}
在模型外进行乱序,每次调用都会进行一次乱序。
// [question randomOptions];
五、添加蒙版
- (UIButton *)cover
{
if (_cover == nil) {
// 添加蒙版(遮罩)
_cover = [[UIButton alloc] initWithFrame:self.view.bounds];
_cover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
[self.view addSubview:_cover];
[_cover addTarget:self action:@selector(bigImage:) forControlEvents:UIControlEventTouchUpInside];
}
return _cover;
}
// // 添加蒙版(遮罩)
// UIButton *cover = [[UIButton alloc] initWithFrame:self.view.bounds];
//
// cover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
//
// [self.view addSubview:cover];
//
// [cover addTarget:self action:@selector(smallImage:) forControlEvents:UIControlEventTouchUpInside];
}
将图像弄到蒙版前面
// bringSubviewToFront 将子视图前置
[self.view bringSubviewToFront:self.iconButton];
设置蒙版的模糊程度
self.cover.alpha = 0.0;
self.cover.alpha = 1.0;
六、更改状态栏的颜色
/**
* 调整状态栏颜色
UIStatusBarStyleDefault = 0, // Dark content, for use on light backgrounds
UIStatusBarStyleLightContent NS_ENUM_AVAILABLE_IOS(7_0) = 1, // Light content, for use on dark backgrounds
*/
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
七,等待一段时间进入 一个方法
[self performSelector:@selector(nextQuestion:) withObject:nil afterDelay:0.5];
八、textField 设置字数限制
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
int loc = range.location;
return (loc < 6);
}
<!DOCTYPE html>
<html>
<head>
<title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="rule.css">
<script>
function btnClick()
{
window.location.href = "#howtorecharge";
}
</script>
</head>
<body>
<input type="button" value = "按钮baby" onClick = "btnClick()">
<div>
一、按钮不能交互的几种情况
1,alpha <= 0.01 (0.02就能点了)
2,hidden = YES
3, userInteraction = NO
4, 所在的父视图不允许交互,按钮也不能交互
5,在父视图可见范围内可以交互,超出范围的部分不能交互。
二、UIImageView 默认 不允许用户交互的。
三、乱序
- (void)randomOptions
{
// 对option数组乱序
[self.options sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) {
int seed = arc4random_uniform(2);
if (seed) {
return [str1 compare:str2];
} else {
return [str2 compare:str1];
}
}];
}
四、模型内进行乱序,只在加载的时候做一次乱序。
- (instancetype)initWithDict:(NSDictionary *)dict
{
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dict];
// 对备选按钮进行乱序,只在加载的时候做一次乱序
[self randomOptions];
}
return self;
}
在模型外进行乱序,每次调用都会进行一次乱序。
// [question randomOptions];
五、添加蒙版
- (UIButton *)cover
{
if (_cover == nil) {
// 添加蒙版(遮罩)
_cover = [[UIButton alloc] initWithFrame:self.view.bounds];
_cover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
[self.view addSubview:_cover];
[_cover addTarget:self action:@selector(bigImage:) forControlEvents:UIControlEventTouchUpInside];
}
return _cover;
}
// // 添加蒙版(遮罩)
// UIButton *cover = [[UIButton alloc] initWithFrame:self.view.bounds];
//
// cover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
//
// [self.view addSubview:cover];
//
// [cover addTarget:self action:@selector(smallImage:) forControlEvents:UIControlEventTouchUpInside];
}
将图像弄到蒙版前面
// bringSubviewToFront 将子视图前置
[self.view bringSubviewToFront:self.iconButton];
设置蒙版的模糊程度
self.cover.alpha = 0.0;
self.cover.alpha = 1.0;
六、更改状态栏的颜色
/**
* 调整状态栏颜色
UIStatusBarStyleDefault = 0, // Dark content, for use on light backgrounds
UIStatusBarStyleLightContent NS_ENUM_AVAILABLE_IOS(7_0) = 1, // Light content, for use on dark backgrounds
*/
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
七,等待一段时间进入 一个方法
[self performSelector:@selector(nextQuestion:) withObject:nil afterDelay:0.5];
八、textField 设置字数限制
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
int loc = range.location;
return (loc < 6);
}
相关文章推荐
- 设置tableview的滚动范围--iOS开发系列---项目中成长的知识三
- 当数据量很少的时候,tableview会显示多余的cell--iOS开发系列---项目中成长的知识二
- 斯坦福iOS7 2013-2014秋Assignment 6的一种答案 #5
- 把所有界面的状态栏字体颜色设置为白色--iOS开发系列---项目中成长的知识一
- iOS开发遇到的坑之四--图片命名不规范
- IOS开发笔记-01按钮操作-08.git的简单使用
- iOS 中获得键盘的弹出和隐藏
- ios 多线程-GCD-NSOperation
- IOS第二天(点语法、构造方法与discription方法)
- 允许debian wheezy支持IOS7+的iphone.
- nsbundle的一些获取本地信息
- iOS NSAssertionHandler讲解
- IOS开发笔记-01按钮操作-05.IBAction&IBOutlet 06.加法计算器小结 07.关闭键盘
- [转载]iOS9 使用CoreLocation
- IOS 触摸获取坐标点、缩放图片实例
- [iOS开发项目-6] 应用程序管理
- IOS总结 静变量static、全局变量extern、局部变量、实例变量
- IOS自定义动画
- iOS <CoreLocation>定位框架的理解与运用
- iOS8 沙盒路径变化特性