• 【原】UIButton使用汇总


    1、创建按钮的两种方法:

    ·1、动态创建
    btnfont = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnfont setFrame:CGRectMake(100, 10, 120, 40)];
    [btnfont addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    [btnfont setTitle:@"字体" forState:UIControlStateNormal];
    btnfont.backgroundColor=[UIColor clearColor];
    [self.view addSubview:btnfont];
    ·2、在xib文件中已经创建好,通过tag获取按钮
    UIButton *testButton= (UIButton*)[self.view viewWithTag:100];
    [testButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];

    2、   

        addAlarmBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [addAlarmBtn setFrame:CGRectMake(0, 892, 394, 71)];
        [addAlarmBtn setTitle:@"添加闹钟" forState:UIControlStateNormal];
        addAlarmBtn.titleLabel.font = [UIFont systemFontOfSize:26.0];//设置按钮上字体的大小
        [addAlarmBtn addTarget:self
                        action:@selector(addAlarm:)
              forControlEvents:UIControlEventTouchUpInside];
        addAlarmBtn.backgroundColor = [UIColor yellowColor];
        addAlarmBtn.alpha = 0.7f;
        [self.view addSubview:addAlarmBtn];

  • 相关阅读:
    BZOJ4553: [Tjoi2016&Heoi2016]序列
    BZOJ4552: [Tjoi2016&Heoi2016]排序
    BZOJ4551: [Tjoi2016&Heoi2016]树
    BZOJ4556: [Tjoi2016&Heoi2016]字符串
    BZOJ4546: codechef XRQRS
    CC 3-Palindromes(manacher)
    hdu3294(manacher)
    hdu4513(manacher)
    poj3974(manacher)
    CF 518D(概率dp)
  • 原文地址:https://www.cnblogs.com/wengzilin/p/2404587.html
Copyright © 2020-2023  润新知