您的位置:首页 > 移动开发 > IOS开发

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: