我正在尝试为UISearchbar自定义文本字段.下图显示了我完成的一半工作.

我有UISearchbar的子类,并从我的视图控制器调用它.我正试图从文本字段中删除那些深灰色线条.下面是添加到viewcontroller子视图的UISearchbar的实现.
searchbar = [[SearchBar alloc] initWithFrame:CGRectMake(35,78, 250, 17)];
searchbar.backgroundColor = [UIColor clearColor];
searchbar.layer.borderColor = [[UIColor clearColor] CGColor];
searchbar.layer.borderWidth = 0;
for(UIView *view in searchbar.subviews){
if([view isKindOfClass:[UITextField class]]){
UITextField *tf= (UITextField *)view;
tf.layer.borderColor = [[UIColor clearColor] CGColor];
tf.delegate = self;
break;
}
}
[self.view addSubview:searchbar];
searchbar.delegate = self;
Run Code Online (Sandbox Code Playgroud)
UISearchBar子类:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(void)layoutSubviews{
UITextField *searchField;
[[[self subviews] objectAtIndex:0] removeFromSuperview];
[self setTintColor:[UIColor clearColor]];
self.clipsToBounds = YES;
NSUInteger …Run Code Online (Sandbox Code Playgroud) 我正在使用pickerController的视图和uinavigationcontrollerdelegate添加叠加层,如下所示.
-(void)navigationController:(UINavigationController *)navigationController didShowViewController: (UIViewController *)viewController animated:(BOOL)animated{
if ([navigationController.viewControllers count] == 3)
{
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
UIView *plCropOverlay = [[[viewController.view.subviews objectAtIndex:1]subviews] objectAtIndex:0];
plCropOverlay.hidden = YES;
int position = 0;
if (screenHeight == 568)
{
position = 124;
}
else
{
position = 80;
}
CAShapeLayer *circleLayer = [CAShapeLayer layer];
UIBezierPath *path2 = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(0.0f, position, 320.0f, 320.0f)];
[path2 setUsesEvenOddFillRule:YES];
[circleLayer setPath:[path2 CGPath]];
[circleLayer setFillColor:[[UIColor clearColor] CGColor]];
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 320, screenHeight-72) cornerRadius:0];
[path …Run Code Online (Sandbox Code Playgroud) 给定两个输入 i。原始图像 & ii. 蒙版图像,从原始图像中删除背景的最佳方法是什么。
原始图像
遮罩图像
最终的输出将只包含没有背景的狗并且看起来是透明的。我看到掩模图像也是用 OpenCV 创建的。有没有办法只使用现有的掩模图像并生成输出图像?
更新 我尝试过这个
import cv2
# opencv loads the image in BGR, convert it to RGB
img = cv2.imread("originalImage.png")
mask = cv2.imread("maskImage.png")
final = cv2.bitwise_and(img, mask)
cv2.imwrite("final.png", final)
Run Code Online (Sandbox Code Playgroud)
最终图像
有没有办法把背景设置成透明?
我有一个标题标签,定义如下:
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 2
label.setContentCompressionResistancePriority(.init(rawValue: 999), for: .vertical)
return label
}()
private lazy var descriptionLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.lineBreakMode = .byTruncatingTail
return label
}()
Run Code Online (Sandbox Code Playgroud)
titleLabel可以增长并强制收缩descriptionLabel。单元格高度固定为120或78。当单元格高度为78时,高度descriptionLabel为0
两者都添加到UIStackview
private lazy var labelStackView: UIStackView = {
let stackView = UIStackView()
stackView.addArrangedSubview(titleLabel)
stackView.addArrangedSubview(descriptionLabel)
stackView.axis = .vertical
stackView.distribution = .fill
return stackView
}()
Run Code Online (Sandbox Code Playgroud)
stackView 添加containerView到顶部、左侧、右侧和底部的填充内部。固定containerView在 的边缘 …
我有一个类似下面给出的目录结构.
MainFolder
|
[lib]
/ | \
[A] [B] [C] -- file1.so
| | file2.so
file1.so file1.so
file2.so file2.so
Run Code Online (Sandbox Code Playgroud)
我正在尝试在该结构中寻找可能不存在的'lib'文件夹.所以我使用以下内容来检查'lib'文件夹是否存在:
if os.path.isdir(apkLocation + apkFolder + '/lib/'):
Run Code Online (Sandbox Code Playgroud)
如果存在lib文件夹,那么我继续搜索'lib'中的文件夹.我必须存储文件夹A,B和C的名称,并查找以".so"结尾的文件,其路径应存储为/lib/A/file1.so,/lib/A/file2.so等等上.
if os.path.isdir(apkLocation + apkFolder + '/lib/'):
for root, dirs, files in os.walk(apkLocation + apkFolder):
for name in files:
if name.endswith(("lib", ".so")):
print os.path.abspath(name)
Run Code Online (Sandbox Code Playgroud)
这让我出局了
file1.so
file2.so
file1.so
file2.so
file1.so
file2.so
Run Code Online (Sandbox Code Playgroud)
期望的输出:
/lib/A/file1.so
/lib/A/file2.so
/lib/B/file1.so
/lib/B/file2.so
/lib/C/file1.so
/lib/C/file2.so
Run Code Online (Sandbox Code Playgroud)
文件夹A,B和C也要单独保存.
我有一个表格的MySQL表格:
id | error 1 | error 2 | error 3 | error 4 |
--------------------------------------------
1 | 1 | 0 | 0 | 1 |
-------------------------------------------
2 | 0 | 0 | 0 | 0 |
Run Code Online (Sandbox Code Playgroud)
id是主键,错误是布尔列.有没有办法我可以获取行的ID,如果任何错误是1为真,如果所有错误都为零,则为false.
ios ×3
python ×2
autolayout ×1
directory ×1
mysql ×1
objective-c ×1
opencv ×1
path ×1
php ×1
quartz-core ×1
sql ×1
uibezierpath ×1
uisearchbar ×1
uistackview ×1
uitextfield ×1