1.爲UILable添加點擊手勢
UILabel *text01 = [[UILabel alloc]initWithFrame:CGRectMake(0, mView.height/5+1, mView.width, mView.height/5)];
text01.text = @"還沒有賬號?點擊註冊吧!";
text01.textColor = [kTabBarColor];
text01.textAlignment = NSTextAlignmentCenter;
text01.font = [UIFont systemFontOfSize:14];
text01.userInteractionEnabled = YES;//重要,很容易被遺忘的一句話
UITapGestureRecognizer *tapToRegister = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toRegister:)];
tapToRegister.numberOfTouchesRequired = 1;//只處理一個手指的觸碰事件
[text01 addGestureRecognizer:tapToRegister];
[mView addSubview:text01];
#pragma mark -點擊,跳轉到註冊頁面
-(void)toRegister:(UITapGestureRecognizer *)gesture{
NSLog(@"go to register...");
}
2.如何製作圓形圖片UIImageView,並添加白色邊框
UIImageView *mHeadImg = [[UIImageView alloc]initWithFrame:CGRectMake(kScreen_width/2-35, kScreen_height/5-10, 70, 70)];
mHeadImg.image = [UIImage imageNamed:@"圓形人物上傳頭像"];
mHeadImg.layer.borderColor = [[UIColor whiteColor] CGColor];
mHeadImg.layer.borderWidth = 2.0f;
mHeadImg.layer.cornerRadius = 35;
[self.view addSubview:mHeadImg];
效果圖:
3.如何實現這種效果:
代碼如下:
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.0f/255.0 green:194.0f/255.0 blue:194.0f/255.0 alpha:1.0];
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:18],
NSForegroundColorAttributeName:[UIColor whiteColor]}];
self.navigationItem.title = @"設置";
self.view.backgroundColor = [UIColor colorWithRed:235/255.0 green:236/255.0 blue:237/255.0 alpha:1];