我只是创建自己的自定义按钮,看起来像iOS6和更早的按钮,但在iOS7上我的CustomButton突出显示时变为透明.我试着设置属性adjustsImageWhenHighlighted在NO但没有任何改变,[self setAlpha:1.f]也不起作用.
以下是我的init方法:
-(void) baseInit:(CGRect)frame :(CGFloat *)colorsNormal :(CGFloat *)colorsHighlighted :(CGFloat *)colorsDisabled
{
self.layer.borderWidth=1.0f;
self.layer.borderColor=[[UIColor colorWithRed:0.67f green:0.67f blue:0.67f alpha:1.0f] CGColor];
self.layer.cornerRadius=7.0f;
self.clipsToBounds = YES;
UIImage *image = [self generateUIImageWithGradient:frame :colorsNormal];
[self setBackgroundImage:image forState:UIControlStateNormal];
[self setTitleColor:[UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f] forState:UIControlStateNormal];
UIImage *image2 = [self generateUIImageWithGradient:frame :colorsHighlighted];
[self setBackgroundImage:image2 forState:UIControlStateHighlighted];
[self setTitleColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] forState:UIControlStateHighlighted];
UIImage *image3 = [self generateUIImageWithGradient:frame :colorsDisabled];
[self setBackgroundImage:image3 forState:UIControlStateDisabled];
}
-(id) generateUIImageWithGradient:(CGRect)frame :(CGFloat *)colors
{
CGSize size = CGSizeMake(frame.size.width, frame.size.height);
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
CGContextRef context …Run Code Online (Sandbox Code Playgroud) 我需要得到只有一周整数的一天字符串(例如:1 =星期一,5 =星期五......),我没有任何日期.
我知道我可以定义一个字符串数组,但我认为使用日期格式有更好的解决方案.没有约会可能吗?
我有一个HTML文件保存在一个临时目录中,如下所示:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentDirectory = NSTemporaryDirectory();
NSString *documentPath = [documentDirectory stringByAppendingPathComponent:@"mydocument.html"];
[fileManager createFileAtPath:documentPath contents:myHTMLDocumentData attributes:nil];
Run Code Online (Sandbox Code Playgroud)
该文档在我的临时文件中创建.在它之后,我想在Safari中打开这个文档,但它不起作用:
NSURL *url = [NSURL fileURLWithPath:documentPath];
[[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)
屏幕上没有任何事情发生,没有错误......但是,如果我用@"http://google.fr"替换"url",则会使用google.fr启动Safari,我可以通过输入网址来访问我的临时文件" Safari中的文件://localhost..../myHtmlDocument.html".
希望你能帮我
我在DialogFragment中使用ArrayAdapter,可以在Android 4.0及更高版本上运行,但在2.3版本中不行.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dialog, null);
Spinner spReglement;
spReglement = (Spinner)view.findViewById(R.id.listReglements);
ArrayAdapter<String> adapterList = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
adapterList.setDropDownViewResource(R.layout.customspinner);
spReglement.setAdapter(adapterList);
HashMap<Integer, String> mapReglement = new HashMap<Integer, String>();
mapReglement.put(-1, "");
adapterList.add("");
for(int i=0; i<alReglement.size();i++){
String libelle = String.valueOf(alReglement.get(i).get("Libelle"));
mapReglement.put(i, libelle);
adapterList.add(libelle);
}
builder.setView(view)
.setPositiveButton("Valider", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mListener.onDialogPositiveClick(DialogFSE.this);
}
})
.setNegativeButton("Annuler", new DialogInterface.OnClickListener() { …Run Code Online (Sandbox Code Playgroud)