如何在WebView中更改下拉列表视图的颜色?

时间:2017-10-23 14:51:10

标签: android android-layout listview webview

@interface ViewController ()

@property (strong) NSTextFinder *textFinder;
@property (weak) IBOutlet NSTextView *textView; // find Uses Bar, Incremental Searching is on
@property (weak) NSView *myFindBarView;
@property (weak) IBOutlet NSView *findBarContainerView; // hidden
@property BOOL barVisible;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textFinder = [[NSTextFinder alloc] init];
    self.textFinder.incrementalSearchingEnabled = YES;
    self.textFinder.incrementalSearchingShouldDimContentView = YES;
    self.textFinder.client = (id<NSTextFinderClient>)self.textView;
    self.textFinder.findBarContainer = self;
    [self.textFinder performAction:NSTextFinderActionShowFindInterface];
}

- (IBAction)testSearchString:(id)sender {
    // action method of a Test button, searches for "found"
    [self.textFinder cancelFindIndicator];

    // search the subviews for a view of class NSSearchField
    __block __weak NSSearchField *(^weak_findSearchField)(NSView *);
    NSSearchField *(^findSearchField)(NSView *);
    weak_findSearchField = findSearchField = ^(NSView *view) {
        if ([view isKindOfClass:[NSSearchField class]])
            return (NSSearchField *)view;
        __block NSSearchField *foundView = nil;
        [view.subviews enumerateObjectsUsingBlock:^(NSView *subview, NSUInteger idx, BOOL *stop) {  
            foundView = weak_findSearchField(subview);
            if (foundView)
                *stop = YES;
        }];
        return foundView;
    };

    NSSearchField *searchField = findSearchField(self.myFindBarView);
    [searchField setStringValue:@"found"];
    // execute the action of the search field to confirm the new value and do a search
    [searchField sendAction:searchField.action to:searchField.target];
    /* add to select all
    [self.textFinder performAction:NSTextFinderActionSelectAll];
    */
}

// NSTextFinderBarContainer

- (void)findBarViewDidChangeHeight {
}

- (NSView *)findBarView {
    return self.myFindBarView;
}

- (void)setFindBarView:(NSView *)theView {
    self.myFindBarView = theView;
    if (theView) {
        NSRect frame = theView.frame;
        frame.size.width = self.findBarContainerView.bounds.size.width;
        theView.frame = frame;
        [self.findBarContainerView addSubview:theView];
    }
}

- (NSView *)contentView {
    return self.textView.enclosingScrollView.contentView;
}

- (BOOL)isFindBarVisible {
    return self.barVisible;
}

- (void)setFindBarVisible:(BOOL)theVisible {
    self.barVisible = theVisible;
}

@end

当我给文字颜色黑色时 低端设备 - 文本颜色 - 黑色,列表视图背景-black,因此无法看到 其他设备 - 文本颜色 - 白色,列表视图背景 - 黑色,所以可以看到 nexus 7 - 文本颜色 - 白色,列表视图背景-black,所以可以看到

当我将文字颜色设为白色时 低端设备 - 文本颜色 - 白色,列表视图背景 - 黑色,所以可以看到 其他设备 - 文本颜色 - 白色,列表视图背景 - 黑色,所以可以看到 nexus 7 - 文本颜色 - 黑色,列表视图背景-black,因此无法看到

1 个答案:

答案 0 :(得分:0)

我解决这个问题的方法是我包装我想要包含文本颜色的html:

.net

&#34; text&#34;在这种情况下,变量是您要显示的html。其他一切都只是该文本的样式。