我使用分段控件而不是按钮。如何设置所选段的背景颜色。我试图改变背景颜色,但它的颜色出现在所有片段中。
答案 0 :(得分:0)
首先,创建您选择和取消选择的颜色;
UIColor *selectedColor = [UIColor blackColor];
UIColor *deselectedColor = [UIColor whiteColor];
然后,找到所选的段索引并给它颜色;
for (UIControl *subview in [YourSegmentedControl subviews]) {
if ([subview isSelected])
[subview setTintColor:selectedColor];
else
[subview setTintColor:deselectedColor];
}
答案 1 :(得分:0)
如果您选择了第一个索引,请编写此代码。
mutliprocessing
如果设置背景颜色,请编写此代码
# encoding=utf-8
import datetime
import multiprocessing
import psycopg2
def exe(cmd):
conn = psycopg2.connect("dbname = test user = pj password = dbrgdbrg")
cur = conn.cursor()
try:
sql = "SELECT id FROM test WHERE ST_MAKEENVELOPE(118,38,119,39,4326) && wkb_geometry;"
cur.execute(sql)
print cur.fetchone()
except Exception, e:
print e
if __name__ == "__main__":
cmds=range(5)
for cmd in cmds:
p = multiprocessing.Process(target=exe,args=(cmd,))
p.start()
p.join()
如果更改色调颜色和字体大小,请编写此代码。
UPDATE table_a
SET sequence_column = (select rn
from (
select rowid,
row_number() over (order by col1, col2) AS RN
from table_a
) x
where x.rowid = table_a.rowid)
答案 2 :(得分:0)
我为你的问题尝试了一个示例。我在XIB中设置了段控件。我还设置了三个title.I将段连接到具有属性和操作的ViewController.h。
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
}
@property (strong, nonatomic) IBOutlet UISegmentedControl *segmentBgColorChange;
- (IBAction)actionChangeBGColor:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
{
}
@end
@implementation ViewController
@synthesize segmentBgColorChange;
// Then in action methods
- (IBAction)actionChangeBGColor:(id)sender
{
UISegmentedControl *seg = sender;
for (int i=0; i<[seg.subviews count]; i++) {
if ([[seg.subviews objectAtIndex:i]isSelected]) {
UIColor *bgColor = [UIColor redColor];
[[seg.subviews objectAtIndex:i] setTintColor:bgColor];
} else {
[[seg.subviews objectAtIndex:i] setTintColor:nil];
}
}
}