iOS指定位置拉扯圖片

本文首發地址

這裏寫圖片描述

UIImage * CharacterBtnImage = [UIImage imageNamed:@"whiteBack"];
    CharacterBtnImage = [CharacterBtnImage stretchableImageWithLeftCapWidth:CharacterBtnImage.size.width * 0.5 topCapHeight:CharacterBtnImage.size.height * 0.5];

    UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(10, 100, 280, 50);
    [btn1 setTitle:@"登陸" forState:UIControlStateNormal];
    [btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.view addSubview:btn1];
    // 這裏一定要用 setBackgroundImage
    [btn1 setBackgroundImage:CharacterBtnImage forState:UIControlStateNormal];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章