Bonjour

J'ai créér un petit projet me permettant de modifier la luminosité ( ou plutot la transparence ) d'un champ
UIlabel

Voici le code

Fichier .m

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
//  Control_Box_CookeAppDelegate.m
//  Control Box Cooke
//
//  Created by Bruno on 1/11/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "SerialManager.h"
#import "Control_Box_CookeAppDelegate.h"
#import "PickerViewController.h"
#include <fcntl.h>
#include "Led.h"


@implementation Control_Box_CookeAppDelegate

@synthesize window;

/*
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch
    [window makeKeyAndVisible];
	
}*/

//RootViewController.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
	
	pvController = [[PickerViewController alloc] initWithNibName:@"pickerview"/*@"MainWindow"*//*@"Control Box Cooke"*//*@"PickerView"*/ bundle:[NSBundle mainBundle]];
	Led_Operateur= [[Led alloc] initWithFrame:CGRectMake(20,50,280,20)];
	Led_Operateur.text=@" ";
	[Led_Operateur setBackgroundColor: [ UIColor colorWithWhite:1.0 alpha: 0.5]];
	[pvController.view addSubview:Led_Operateur];
	[window addSubview:pvController.view];
	

		
	// Override point for customization after application launch
	[window makeKeyAndVisible];
	

	
}


- (void)dealloc {
	[Led_Operateur release];
	[pvController release];
[window release];
    [super dealloc];
}

-(void)Modifie_luma:(CGFloat)luma
{
	pvController = [[PickerViewController alloc] initWithNibName:@"pickerview" bundle:[NSBundle mainBundle]];
	Led_Operateur= [[UILabel alloc] initWithFrame:CGRectMake(20,50,280,20)];
	Led_Operateur.text=@" ";
	[Led_Operateur setBackgroundColor: [ UIColor colorWithWhite:1.0 alpha: luma]];
	[pvController.view addSubview:Led_Operateur];
	[window addSubview:pvController.view];
	[window makeKeyAndVisible];
}

@end
fichier .h

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
//  Control_Box_CookeAppDelegate.h
//  Control Box Cooke
//
//  Created by Bruno on 1/11/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SerialManager.h"
#import "led.h"

@class PickerViewController;

@interface Control_Box_CookeAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	PickerViewController *pvController;
		SerialManager *portCunima;
	int port_in,port_out;  // numero de port de com in-out
	UILabel *Led_Operateur;

}

-(void)Modifie_luma:(CGFloat)luma;

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

A l'init pas de problème mon champs UILabel s'affiche bien avec la transparence
de 50% ( alpha=0.5)

Par contre quand je modifie cette transparence à l'aide d'un bouton
j'appelle l'instance Modifie_Luma qui est dans la classe
Control_Box_CookeAppDelegate

le progamme pas bien par cette instance, (j'ai mis un point d'arrêt) mais impossible de faire varier cette transparence.

Pourtant si je change dans l'instance (void)applicationDidFinishLaunching
la transparence

exemple alpha =0,5 => alpha =0,8

Code : Sélectionner tout - Visualiser dans une fenêtre à part
	[Led_Operateur setBackgroundColor: [ UIColor colorWithWhite:1.0 alpha: 0.8]];
cet exemple ça marche

resumé

quand je change la transparence dans l'instance
(void)applicationDidFinishLaunching ça marche

quand je change la transparence dans l'instance
-(void)Modifie_luma ça marche pas


Avez vous une explication ?