如何在Xcode的故事板上更改文本视图的背景

问题描述

我在xcode故事板上遇到了问题,无法设置应用程序的图形。 没什么复杂的,但是我真的不明白逻辑。

  1. 导入将作为背景的图像视图。设置为不透明,alpha = 1,它使用在Internet上找到的图像,背景为“默认”。它覆盖了整个iPhone表面

  2. 导入文本视图。现在,我正在尝试使文本视图的背景色为白色。 为此,在“文本字段”部分,我尝试使用在互联网上找到的白色图像,但没有成功。我还尝试在“视图”部分中将“背景”设置为Alpha = 1且激活为不透明的白色,但没有成功,文本视图背景看起来与背景图片完全一样,但并不突出。

有人知道怎么做吗?

解决方法

万一有人想知道,我已经可以使用像这样的代码行以编程方式解决此问题:

import {OnInit,Component,ViewChild} from '@angular/core';
import {FormControl,Validators} from '@angular/forms';
import {MatTableDataSource} from '@angular/material/table';
import {MatSort} from '@angular/material/sort';
import {MatPaginator} from '@angular/material/paginator';

@Component({
  selector: 'app-home',templateUrl: './home.component.html',styleUrls: ['./home.component.scss']
})

export class HomeComponent implements OnInit {

  originFormControl = new FormControl('',[
    Validators.required,]);

  destinationFormControl = new FormControl('',]);

  datesFormControl = new FormControl('',]);

  filterValues = {
    origin: '',destination: ''
  };

  // Sets the min date as current date
  todayDate:Date = new Date();

  constructor() {
    this.dataSource.filterPredicate = this.createFilter();
  }

  ngOnInit() {
    this.originFormControl.valueChanges
      .subscribe(
        origin => {
          this.filterValues.origin = origin;
          this.dataSource.filter = JSON.stringify(this.filterValues);
        }
      )
    this.destinationFormControl.valueChanges
      .subscribe(
        destination => {
          this.filterValues.destination = destination;
          this.dataSource.filter = JSON.stringify(this.filterValues);
        }
      )
  }

  createFilter(): (data: any,filter: string) => boolean {
    let filterFunction = function(data,filter): boolean {
      let searchTerms = JSON.parse(filter);
      return data.origin && data.origin.toLowerCase().indexOf(searchTerms.origin) !== -1
        && data.destination && data.destination.toString().toLowerCase().indexOf(searchTerms.destination) !== -1
    }
    return filterFunction;
  }

  displayedColumns: string[] = ['carrierName','origin','destination','price','action'];
  dataSource = new MatTableDataSource<Carriers>(ELEMENT_DATA);

  @ViewChild(MatSort) sort: MatSort;
  @ViewChild(MatPaginator) paginator: MatPaginator;

  ngAfterViewInit() {
    this.dataSource.sort = this.sort;
    this.dataSource.paginator = this.paginator;
  }

}

export interface Carriers {
  carrierName: string;
  originCity: string;
  originState: string;
  destinationCity: string;
  destinationState: string;
  price: number;
  startDate: string;
  endDate: string;
  action: string;
}

const ELEMENT_DATA: Carriers[] = [
  {carrierName: 'Test',originCity: 'Minneapolis',originState: 'MN',destinationCity: 'Richmond',destinationState: 'VA',price: 1800,startDate: '11/11/2020 16:16',endDate: '11/20/2020 16:16',action: "Book Carrier"},{carrierName: 'Test',originCity: 'Eugene',originState: 'OR',destinationCity: 'Portland',destinationState: 'OR',originCity: 'Richmond',originState: 'VA',originCity: 'Charlottesville',originCity: 'Denver',originState: 'CO',];

仍然不确定为什么它在界面构建器上不起作用。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...