澳门皇冠金沙网站-澳门皇冠844网站

热门关键词: 澳门皇冠金沙网站,澳门皇冠844网站

代码笔记

【代码笔记】iOS-4个可以单独点击的button,ios-4button

一,效果图。

皇冠体育网页 1

二,工程图。

皇冠体育网页 2

三,代码。

ViewController.m

皇冠体育网页 3

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    //初始化背景图
    [self addBackGroundView];

}
#pragma -mark -functions
//初始化背景图
-(void)addBackGroundView
{
    //4个连着的button
    for (int i=0; i<4; i  ) {

        UIButton *chooseButton=[UIButton buttonWithType:UIButtonTypeCustom];
        chooseButton.frame=CGRectMake(0 80*i,50, 80, 38);
        chooseButton.tag=i;
        if (i==0) {
            [chooseButton setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getno1"] forState:UIControlStateNormal];
        }else if (i==1){
            [chooseButton setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getyes1"] forState:UIControlStateNormal];
        }else if (i==2){
            [chooseButton setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workno1"] forState:UIControlStateNormal];
        }else if (i==3){
            [chooseButton setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workyes1"] forState:UIControlStateNormal];
        }
        [chooseButton setBackgroundColor:[UIColor clearColor]];
        [chooseButton addTarget:self action:@selector(doClickChooseButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:chooseButton];

    }

}
#pragma -mark -doClickActions
//4个按钮
-(void)doClickChooseButton:(UIButton *)btn
{
    NSLog(@"---doClickChooseButton--");
    if (btn.tag==0) {
        if (btn.selected==NO) {
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getno2"] forState:UIControlStateNormal];
            btn.selected=YES;
        }else{
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getno1"] forState:UIControlStateNormal];
            btn.selected=NO;
        }

    }else if (btn.tag==1){
        if (btn.selected==NO) {
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getyes2"] forState:UIControlStateNormal];
            btn.selected=YES;
        }else{
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_getyes1"] forState:UIControlStateNormal];
            btn.selected=NO;
        }

    }else if (btn.tag==2){
        if (btn.selected==NO) {
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workno2"] forState:UIControlStateNormal];
            btn.selected=YES;
        }else{
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workno1"] forState:UIControlStateNormal];
            btn.selected=NO;
        }

    }else if (btn.tag==3){
        if (btn.selected==NO) {
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workyes2"] forState:UIControlStateNormal];
            btn.selected=YES;
        }else{
            [btn setBackgroundImage:[UIImage imageNamed:@"shoplist_tab_workyes1"] forState:UIControlStateNormal];
            btn.selected=NO;
        }

    }

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

皇冠体育网页 4

一,效果图。 二,工程图。 三,代码。 ViewController.m #import " ViewController.h " @interface V...

【代码笔记】iOS-MBProgressHUD MJ,iosmbprogresshudmj

一,效果图。

皇冠体育网页 5

二,工程图。

皇冠体育网页 6

三,代码。

ViewController.m

皇冠体育网页 7

#import "ViewController.h"
#import "MBProgressHUD MJ.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [MBProgressHUD showMessage:@"正在登录" toView:self.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

一,效果图。 二,工程图。 三,代码。 ViewController.m #import " ViewController.h " #import " MBProgress...

【代码笔记】iOS-可拷贝的label,ios-label

皇冠体育网页,一,效果图。

皇冠体育网页 8

澳门皇冠赌场网页,二,工程图。

皇冠体育网页 9

三,代码。

ViewController.m

皇冠体育网页 10

#import "ViewController.h"
#import "MKBeCopyLabel.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    MKBeCopyLabel *copyLabel = [[MKBeCopyLabel alloc]initWithFrame:CGRectMake(10, 100, 100, 60)];
    copyLabel.backgroundColor=[UIColor redColor];
    copyLabel.text=@"111111";
    copyLabel.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapCopyText = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapToCopyText:)];
    [copyLabel addGestureRecognizer:tapCopyText];
    [self.view addSubview:copyLabel];

}
- (void)handleTapToCopyText:(UITapGestureRecognizer *)sender
{
    MKBeCopyLabel * targetLabel = (MKBeCopyLabel *)sender.view;
    [targetLabel handleLongTap];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

皇冠体育网页 11

一,效果图。 二,工程图。 三,代码。 ViewController.m #import " ViewController.h " #import " MKBeCopyLabel.h "...

本文由澳门皇冠金沙网站发布于网络操作,转载请注明出处:代码笔记