как показать и скрыть div при нажатии кнопки, используя jquery [duplicate]

Использовать протокол UIAppearance. Сделайте больше хаков с appearanceFont, чтобы изменить шрифт для UIAlertAction.

Создайте категорию для UILabel

UILabel + FontAppearance.h

@interface UILabel (FontAppearance)

@property (nonatomic, copy) UIFont * appearanceFont UI_APPEARANCE_SELECTOR;

@end

UILabel + FontAppearance.m

@implementation UILabel (FontAppearance)

- (void)setAppearanceFont:(UIFont *)font
{
    if (self.tag == 1001) {
        return;
    }

    BOOL isBold = (self.font.fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold);
    const CGFloat* colors = CGColorGetComponents(self.textColor.CGColor);

    if (self.font.pointSize == 14) {
        // set font for UIAlertController title
        self.font = [UIFont systemFontOfSize:11];
    } else if (self.font.pointSize == 13) {
        // set font for UIAlertController message
        self.font = [UIFont systemFontOfSize:11];
    } else if (isBold) {
        // set font for UIAlertAction with UIAlertActionStyleCancel
        self.font = [UIFont systemFontOfSize:12];
    } else if ((*colors) == 1) {
        // set font for UIAlertAction with UIAlertActionStyleDestructive
        self.font = [UIFont systemFontOfSize:13];
    } else {
        // set font for UIAlertAction with UIAlertActionStyleDefault
        self.font = [UIFont systemFontOfSize:14];
    }
    self.tag = 1001;
}

- (UIFont *)appearanceFont
{
    return self.font;
}

@end

Использование:

добавить

[[UILabel appearanceWhenContainedIn:UIAlertController.class, nil] setAppearanceFont:nil];

в AppDelegate.m, чтобы сделать это работа для всех UIAlertController.

-4
задан karal kunal 16 January 2019 в 11:10
поделиться

3 ответа

Используйте .toggle () в jquery

$("#btnsearch").click(function () {
        $("#Show").toggle();
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button type="button" id="btnsearch" style="background-color: white">Search</button>
<div id="Show">ff</div>

0
ответ дан ellipsis 16 January 2019 в 11:10
поделиться

Вы можете использовать функцию jquery toggle () для задачи

 $("#btnsearch").click(function(){
    $("#Show").toggle();
  });

. С помощью функции jquery toggle () автоматически скрыть и показать целевой элемент #Show

0
ответ дан Ayaz Shah 16 January 2019 в 11:10
поделиться

Попробуйте это

$(document).ready(function(){
  $("button").click(function(){
    $("#toggle").toggle();
  });
});
div {
height:200px;
width:200px;
background-color:red;
}
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

</head>
<body>

<div id="toggle">
</div>

<button>Toggle between hide() and show()</button>

</body>
</html>

0
ответ дан Biswajit Nath 16 January 2019 в 11:10
поделиться
Другие вопросы по тегам:

Похожие вопросы: