iOS - Setting UIButton background color only colors the corners

前端 未结 3 1297
时光取名叫无心
时光取名叫无心 2021-01-04 05:34

I\'m trying to customize my button by changing their colors, but when I use either:

self.loginButton.layer.backgroundColor = [UIColor colorWithRed:0.0 green:         


        
相关标签:
3条回答
  • 2021-01-04 05:47

    You're using a round rect button which is pretty ugly, and pretty hard to customise.

    You can create a custom type button and use a background image, or create a custom type button and round the corners and set the background colour of the layer yourself.

    If you want to get really fancy there is a nice tutorial here which can give you any-sized gradient type buttons using layers, no image files required.

    0 讨论(0)
  • 2021-01-04 06:04

    I discovered this almost by accident:

    self.loginButton.tintColor = [UIColor redColor];
    

    Definitely works and has been available since iOS 2.0.

    0 讨论(0)
  • 2021-01-04 06:09

    What's that button type? If you want to customise button, you gotta create a button with [UIButton buttonWithType:UIButtonTypeCustom]

    0 讨论(0)
提交回复
热议问题