Set a custom buttons font without being overridden by the value set in the storyboard

Russell Cargill

I have a custom button, AdvisorButton.h and within the init I set the font of the button but I believe they are being overridden by the storyboard settings for the button.

Heres the implementation:

-(id)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame]))
    {
        [self initializationCodeMethod];
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder
{
    if ((self = [super initWithCoder:aDecoder]))
    {
        [self initializationCodeMethod];
    }
    return self;
}

-(id)initializationCodeMethod
{

    if(self.tag == 1)
    {
        UIFont *theFont = [UIFont fontWithName:@"DINOT-Light" size:20];
        [self.titleLabel setFont:theFont];
    }
    else
    {
        UIFont *theFont = [UIFont fontWithName:@"VWHeadlineOT-Book" size:20];
        [self.titleLabel setFont:theFont];
    }
    return self;
}

The font objects are initialised properly and if i print them out the have value etc.

The problem is they are defined in the storyboard and I want to avoid referencing every button/label/textfield in their view controllers just to set the font.

Am I right in thinking that the storyboard values are being set after the init function call?

Any insight into this problem would prove useful!

EDIT: Note that I checked the font before trying to set it, and its set to the default font from the storyboard which is fine.

I then check it again after it is supposedly set and its still the exact same.

Russell Cargill

Solved

It turns out of the text of the object on the storyboard is anything other than the system default any changes are overridden by the storyboard settings.

I personally had attributed text with underline etc and it did not update.

I removed the attributes but left another font other than default and it failed to replace the font.

Therefore I set it back to default and it then allowed me to replace the font.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Set custom user-agent value in Microsoft Outlook Today

분류에서Dev

codeigniter form_dropdown, set option value without an array

분류에서Dev

wifi options not being set to disable power / how to reload wifi setting changes without rebooting

분류에서Dev

Why is the value of a cookie I'm setting (a string) increasing by one when being set from a $_GET?

분류에서Dev

set form fields when buttons are pressed

분류에서Dev

Make setxkbmap preferences being set at startup

분류에서Dev

$scope variable being undefined despite being set inside a $watch function

분류에서Dev

rating value not set

분류에서Dev

Set null object to a value

분류에서Dev

Select custom attribute to set style

분류에서Dev

How to set MSI custom property

분류에서Dev

How to set custom button in custom dialog box?

분류에서Dev

Difference between set variable "value" and set variable value?

분류에서Dev

Async onPostExecute Not being called, or correctly overridden

분류에서Dev

Swift - How to set the value of an XCUIElement

분류에서Dev

trying to set the value of a field but it is not working

분류에서Dev

Set session value in Template Django

분류에서Dev

Datetimepicker set value of different format

분류에서Dev

Dynamically set object property value

분류에서Dev

Set a value within a closure swift

분류에서Dev

GLSL set value of predefined variables

분류에서Dev

How to Set a value with words and Cells

분류에서Dev

Set return value as environment variable

분류에서Dev

Using jQuery to check if one in set of radio buttons is checked

분류에서Dev

Set the size of radio buttons styled horizontally , that suit for all screen sizes

분류에서Dev

How to set Style on only Selected button from Group of Buttons

분류에서Dev

vb net set font size based on string length

분류에서Dev

HttpClient Authorization Header not being send when set BrowserRequestMode to NoCors

분류에서Dev

Strange PATH issue in Windows 7 - goes null after being set

Related 관련 기사

  1. 1

    Set custom user-agent value in Microsoft Outlook Today

  2. 2

    codeigniter form_dropdown, set option value without an array

  3. 3

    wifi options not being set to disable power / how to reload wifi setting changes without rebooting

  4. 4

    Why is the value of a cookie I'm setting (a string) increasing by one when being set from a $_GET?

  5. 5

    set form fields when buttons are pressed

  6. 6

    Make setxkbmap preferences being set at startup

  7. 7

    $scope variable being undefined despite being set inside a $watch function

  8. 8

    rating value not set

  9. 9

    Set null object to a value

  10. 10

    Select custom attribute to set style

  11. 11

    How to set MSI custom property

  12. 12

    How to set custom button in custom dialog box?

  13. 13

    Difference between set variable "value" and set variable value?

  14. 14

    Async onPostExecute Not being called, or correctly overridden

  15. 15

    Swift - How to set the value of an XCUIElement

  16. 16

    trying to set the value of a field but it is not working

  17. 17

    Set session value in Template Django

  18. 18

    Datetimepicker set value of different format

  19. 19

    Dynamically set object property value

  20. 20

    Set a value within a closure swift

  21. 21

    GLSL set value of predefined variables

  22. 22

    How to Set a value with words and Cells

  23. 23

    Set return value as environment variable

  24. 24

    Using jQuery to check if one in set of radio buttons is checked

  25. 25

    Set the size of radio buttons styled horizontally , that suit for all screen sizes

  26. 26

    How to set Style on only Selected button from Group of Buttons

  27. 27

    vb net set font size based on string length

  28. 28

    HttpClient Authorization Header not being send when set BrowserRequestMode to NoCors

  29. 29

    Strange PATH issue in Windows 7 - goes null after being set

뜨겁다태그

보관