/*_____________________________UIPageControl_____________________________*/
- (void)_initPageCtrl {
UIPageControl *pageCtrl = [[UIPageControl alloc] initWithFrame:CGRectMake(20, 380, 200, 20)];
// pageCtrl.backgroundColor = [UIColor redColor];
//设置总页数
pageCtrl.numberOfPages = 4;
//设置当前所在页数
pageCtrl.currentPage = 1;
<span style="color:#cc0000;">//设置图标的颜色(未选中)</span>
pageCtrl.pageIndicatorTintColor = [UIColor blackColor];
//添加点击事件
[pageCtrl addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pageCtrl];
}
- (void)pageAction:(UIPageControl *)pg {
// NSLog(@"%d",pg.currentPage);
/*_____________________________提示框_____________________________*/
// 1. UIAlertView
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"
// message:@"确定推出吗?"
// delegate:self
// cancelButtonTitle:@"取消"
// otherButtonTitles:@"确定",@"按钮1", nil];
//
// //窗口样式
// alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
// //显示提示框
// [alertView show];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"提示"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:@"确定"
otherButtonTitles:@"其他1", nil];
//添加到当前视图上显示
// [self.view addSubview:actionSheet]; 错误
[actionSheet showInView:self.view];
}
#pragma mark -UIAlertView delaget
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"点击取消了");
}
else if (buttonIndex == 1)
{
NSLog(@"点击确定了");
UITextField *textField1 = [alertView textFieldAtIndex:0];
NSLog(@"textField1:%@",textField1.text);
UITextField *textField2 = [alertView textFieldAtIndex:1];
NSLog(@"textField2:%@",textField2.text);
}
}
#pragma mark -UIActionSheet delaget
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"buttonIndex:%d",buttonIndex);
}
UIPageControl分页控件和 UIAlertView提示框
最新推荐文章于 2020-10-22 09:56:32 发布