如何解决如何在Xcode的故事板上更改文本视图的背景
我在xcode故事板上遇到了问题,无法设置应用程序的图形。 没什么复杂的,但是我真的不明白逻辑。
-
导入将作为背景的图像视图。设置为不透明,alpha = 1,它使用在Internet上找到的图像,背景为“默认”。它覆盖了整个iPhone表面
-
导入文本视图。现在,我正在尝试使文本视图的背景色为白色。 为此,在“文本字段”部分,我尝试使用在互联网上找到的白色图像,但没有成功。我还尝试在“视图”部分中将“背景”设置为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',];
仍然不确定为什么它在界面构建器上不起作用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。