iOS – 利用UILayer實現扁平化控件、帶弧度的UIButton、圓形的UIImageView: – iPhone手機開發技術文章 iPhone軟體開發教學課程

最近在做扁平化,需要修改一些控件,因為是純代碼,沒法在 xib文件裡面拖,實現之後記錄一下:

UIButton

    UIButton *btnLogin = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btnLogin.frame = CGRectMake(30.0, 275.0, 260.0, 45.0);
    [btnLogin setBackgroundColor:[UIColor colorWithRed:73.0/255.0 green:189.0/255.0 blue:204.0/255.0 alpha:1.0]];
    btnLogin.layer.cornerRadius = 4.0;
    btnLogin.titleLabel.font = ZY_FONT(17.0);
    [btnLogin setTitle:NSLocalizedString(@"ok", nil) forState:UIControlStateNormal];
    [btnLogin setTintColor:[UIColor whiteColor]];
    [btnLogin addTarget:self action:@selector(changePw:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnLogin];

vcD4KPHA+VUlJbWFnZVZpZXc8L3A+CjxwPjxwcmUgY2xhc3M9″brush:java;”> UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(1.0, 5.0, 60.0, 60.0)];
imageView.layer.cornerRadius = imageView.frame.size.height/2;
imageView.layer.masksToBounds = YES;
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[imageView setClipsToBounds:YES];
imageView.layer.shadowColor = [UIColor whiteColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(4.0, 4.0);
imageView.layer.shadowOpacity = 0.5;
imageView.layer.shadowRadius = 2.0;
imageView.layer.borderColor = [UIColor whiteColor].CGColor;
imageView.layer.borderWidth = 2.0f;
imageView.image = [UIImage imageNamed:@”profileIcon.png”];
[cell.contentView addSubview:imageView];

發佈留言