你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS - 利用UILayer實現扁平化控件、帶弧度的UIButton、圓形的UIImageView:

iOS - 利用UILayer實現扁平化控件、帶弧度的UIButton、圓形的UIImageView:

編輯:IOS開發綜合

最近在做扁平化,需要修改一些控件,因為是純代碼,沒法在 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];
\


<喎?/kf/ware/vc/" target="_blank" class="keylink">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];


  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved