IOS开发-设置UIButton 图片在左 文字在右

   UIButton *movableButton = [[UIButton alloc] init];
    movableButton.frame = CGRectMake(SCREEN_WIDTH-100, 160, 90, 30);
    [movableButton addTarget:self action:@selector(goPlist) forControlEvents:UIControlEventTouchUpInside];
    [movableButton setBackgroundColor:[UIColor colorWithHexString:@"#C00023"]];
    [movableButton setImage:[UIImage imageNamed:@"icon_screen"] forState:UIControlStateNormal];
    [movableButton setTitle:@"FILTER" forState:UIControlStateNormal];
    [movableButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [movableButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    movableButton.titleLabel.font = [UIFont systemFontOfSize:15.0f];
    //设置button图片的偏移量,距(top, left, bottom, right)的像素点为(5, 10, 5, 60)
    movableButton.imageEdgeInsets = UIEdgeInsetsMake(5, 10, 5, 60);
    //设置button标题的偏移量,这个偏移量是相对于图片的
    movableButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    [self.view addSubview:movableButton];

你可能感兴趣的:(IOS开发-设置UIButton 图片在左 文字在右)