iOS遇到的细节问题

来源:互联网 发布:北京大数据云计算骗局 编辑:程序博客网 时间:2024/05/17 06:52

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.0blue: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];


0 0
原创粉丝点击